只是一个简单的Python Replace()函数

时间:2016-01-19 09:34:55

标签: python replace

我是Python的初学者尝试使用替换功能,并遇到了这个问题:

quote="Inquiring the application issues"
t=quote.title()        
print(t)                #prints "Inquiring the Application Issues"        
t=t.replace("the","a")  #try to replace "the" to "a" in the title-formatted quote
print(t)               #still prints "Inquiring the Application Issues", "the" didn't get replaced

有人能在这里指出我的问题吗?非常感谢!

2 个答案:

答案 0 :(得分:0)

print(t)#prints"查询应用程序问题"

不打印"查询应用程序问题"?

答案 1 :(得分:0)

使用调试器或交互式shell:

>>> quote="Inquiring the application issues"
>>> t=quote.title()
>>> print(t)
Inquiring The Application Issues

请注意The != the