用正则表达式替换
import re
s = '''i am a student. I am sIx years old. i like read book. I lIke play the piano.
I am a unIversity student. i major in Information management and informatIon system.'''
s = re.sub(r'\bi\b','I',s)
s = re.sub(r'\BI','i',s)
print(s)
如果Information 单词首字母“I”也要转成“i”
可以这样
s = re.sub(r'\BI|I\B','i',s)
import re
s = '''i am a student. I am sIx years old. i like read book. I lIke play the piano.
I am a unIversity student. i major in Information management and informatIon system.'''
s = re.sub(r'\bi\b','I',s)
s = re.sub(r'\BI|I\B','i',s)
print(s)

如有帮助,望采纳!谢谢!