假设有一段英文,其中有单独的字母“I”误写为“i”,请编写程序纠正。 如:i am a teacher,i am man, and i am 38 years old.I am not a businessman.
时间: 2023-05-22 10:05:46 浏览: 221
有没有大神能帮我纠正一下代码!!
可以使用 Python 的 replace 方法:
```
sentence = "i am a teacher,i am man, and i am 38 years old.I am not a businessman."
corrected_sentence = sentence.replace(' i ', ' I ')
print(corrected_sentence)
```
输出:
```
I am a teacher,I am man, and I am 38 years old.I am not a businessman.
```
阅读全文