【发布时间】:2019-05-04 13:51:22
【问题描述】:
我有一个字符串,我知道它包含单词“python”,但我不知道该字符串有多少个字符。 我想添加“。”在“蟒蛇”之前 例如:
str = input("enter string")
#Here I need help
print(str)#The output will be the user's input and "." before the word "python" let say str = "I love python" the output will be "I love .python"
【问题讨论】:
-
你尝试过什么代码来解决它? @VictorHanukayev
-
我不知道怎么解决
-
看看
string.split和string.join方法!他们将帮助您找到解决方案! -
您也可以使用
if条件来检查python是否在用户的输入中,然后将python替换为.python