j.py 345 Bytes Edit 1 2 3 4 5 6 7 8 new_data='' with open(r"C:\Users\grape\Desktop\user.txt",'r',encoding='utf-8') as file1: for data in file1: if '小强:1本' in data: data=data.replace('小强:1本','小强:11本') new_data +=data with open(r"C:\Users\grape\Desktop\user.txt",'w',encoding='utf-8') as file1: file1.write(new_data)