Commit 1c77fc26 by BellCodeEditor

save project

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