Commit c07ebb2a by BellCodeEditor

save project

parent f759352e
Showing with 10 additions and 7 deletions
new_data=''
a=open('C:\\Users\\Windows 7\\Desktop\\test.txt','r',encoding='utf-8') a=open('C:\\Users\\Windows 7\\Desktop\\test.txt','r',encoding='utf-8')
a.write('小兰:12本\n') #a.write('小兰:12本\n')
a.write('小强:11\n') #a.write('小强:10本\n')
a.write('小刚:10\n') #a.write('小刚:13本\n')
a.close() #a.close()
for i in a: for i in a:
if '小强:11本' in i: if '小强:10本' in i:
print('小强在文件中') print('小强在文件中')
\ No newline at end of file data=data.replace('小强:10本','小强:11本')
new_data+=data
\ 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