我对python比较陌生。我想用一个不同的词来替换出现两次以上的单词。单词可以由多个单词组成。我希望他们被XYZ取代。例如: ABC is a tall person. ABC likes sports. Sports are good for health. ABC is a gold medalist in many sports.
ABC和运动应该替换为XYZ。像,上面的句子应该是: X
program1.py: a = "this is a test"
for x in a:
print(x)
program2.py: a = """this is a test
with more than one line
three, to be exact"""
for x in a:
print(x)
program3.py: im