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

2024-06-16 13:25:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我是Python初学者,尝试使用replace函数,遇到了以下问题:

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

有人能指出我的问题吗?非常感谢!你知道吗


Tags: theto函数applicationtitleprintsreplacequote
2条回答

打印(t)#打印“查询申请问题”

不是“询问申请问题”?你知道吗

使用调试器或交互式shell:

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

注意The != the。你知道吗

相关问题 更多 >