Commit 3d1ff4cf by BellCodeEditor

save project

parent b7e38dd7
Showing with 18 additions and 7 deletions
with open(r"C:\Users\Administrator\Desktop\text.txt","r",encoding="utf-8") as file1: with open(r"C:\Users\Administrator\Desktop\text.txt","w",encoding="utf-8") as file1:
#file.write("123456789012345678901234567890\n") file1.write("123\n")
#file.write("098765432109876543210987654321\n") file1.write("321\n")
for data in file1: # for data in file1:
if '098765432109876543210987654321'in data: # if '123'in data:
print('TM的在!!!!!!!') # print('TM的在!!!!!!!')
\ No newline at end of file
new_data=''
with open(r"C:\Users\Administrator\Desktop\text.txt","r",encoding="utf-8") as file1:
for data in file1:
if '123' in data:
data=data.replace('123','321')
new_data+=data
with open(r"C:\Users\Administrator\Desktop\text.txt","w",encoding="utf-8") as file1:
file1.write(new_data)
with open(r"C:\Users\Administrator\Desktop\text.txt","r",encoding="utf-8") as file1:
a=file1.read()
print(a)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment