编写程序,检查字符串"Life is short. I use python”中是否包含字符串"python",若包 含则替换为"Python"后输出新字符串,否则输出原字符串。
时间: 2024-05-12 20:17:24 浏览: 83
【Python入门学习】2.Python字符串相关操作“:查找、拼接、拆分、替换、判断等
好的,我理解了你的问题。以下是Python代码实现:
```
s = "Life is short. I use python"
if "python" in s:
s = s.replace("python", "Python")
print(s)
else:
print(s)
```
运行结果为:
```
Life is short. I use Python
```
阅读全文