Commit aecd1ad5 by BellCodeEditor

save project

parent a8d02629
Showing with 23 additions and 0 deletions
with open('c:\\Users\\Administrator\\Desktop\\100.txt',"a",encoding='utf-8') as f:
f.write('小强:10本\n')
f.write('李明:15本\n')
\ No newline at end of file
new_i=''
with open('c:\\Users\\Administrator\\Desktop\\100.txt',"r",encoding='utf-8') as f:
for i in f:
if '小强:10本' in i:
i=i.replace('小强:10本','小强:11本')
if '小兰:12本' in i:
i=i.replace('小兰:12本','小兰:11本')
new_i +=i
with open('c:\\Users\\Administrator\\Desktop\\100.txt',"w",encoding='utf-8') as f:
f.write(new_i)
with open('c:\\Users\\Administrator\\Desktop\\100.txt',"r",encoding='utf-8') as f:
a=f.read()
print(a)
\ No newline at end of file
with open('c:\\Users\\Administrator\\Desktop\\100.txt',"w",encoding='utf-8') as f:
f.write('小强:10本\n')
f.write('李明:15本\n')
f.write('小兰:12本\n')
\ 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