你可以使用单词边界(
\b
)和re()
\bi\b
图案
import re
s = """with this notice know that i inscribe messages to inform.
a boy named "Will" said into a microphone that time is like a high-five.
i give lines to computers to find cities and sites.
i am my eyes, and to view is to exist (cuanda tu ve, tu comprendes el significado del 'hay')
view that i will not be processing your application any further because i am eating an apple.
--------------------------------------------------------------------------------
wIth thIs notIce know that I InscrIbe messages to Inform.
a boy named "WIll" saId Into a mIcrophone that tIme Is lIke a hIgh-fIve.
I gIve lInes to computers to fInd cItIes and sItes.
I am my eyes, and to vIew Is to exIst (cuanda tu ve, tu comprendes el sIgnIfIcado del 'hay')
vIew that I wIll not be processIng your applIcatIon any further because I am eatIng an apple.
"""
print(re.sub(r'\bi\b', 'I', s))
打印
with this notice know that I inscribe messages to inform.
a boy named "Will" said into a microphone that time is like a high-five.
I give lines to computers to find cities and sites.
I am my eyes, and to view is to exist (cuanda tu ve, tu comprendes el significado del 'hay')
view that I will not be processing your application any further because I am eating an apple.
--------------------------------------------------------------------------------
wIth thIs notIce know that I InscrIbe messages to Inform.
a boy named "WIll" saId Into a mIcrophone that tIme Is lIke a hIgh-fIve.
I gIve lInes to computers to fInd cItIes and sItes.
I am my eyes, and to vIew Is to exIst (cuanda tu ve, tu comprendes el sIgnIfIcado del 'hay')
vIew that I wIll not be processIng your applIcatIon any further because I am eatIng an apple.