Commit 1c77fc26 by BellCodeEditor

save project

parent 84f81d18
Showing with 9 additions and 6 deletions
......@@ -9,11 +9,14 @@ with open('C:\\Users\\Administrator\\Desktop\\test.txt','r',encoding='utf-8') as
#file1.write('小强:12本\n')
#a=file1.read()
#print(a)
new_i=""
for i in file1:
if '小强:12本' in i:
print("在其中")
if '小兰:12本' in i:
print("在其中")
i=i.replace('小强:12本','小强:11本')
new_i+=i
with open('C:\\Users\\Administrator\\Desktop\\test.txt','w',encoding='utf-8') as file1:
file1.write(new_i)
\ No newline at end of file
with open('C:\\Users\\Administrator\\Desktop\\test.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