Commit e9eda480 by BellCodeEditor

auto save

parent 31dc541d
Showing with 16 additions and 0 deletions
with open('C:\\Users\\EDZ\\Desktop\\test.txt', 'w', encoding = 'utf-8') as file:
file.write('小强:12本\n')
file.write('小明:12本\n')
new_data = ''
with open('C:\\Users\\EDZ\\Desktop\\test.txt', 'r', encoding = 'utf-8') as file:
for line in file:
if '小强:12本' in line:
line = line.replace('小强:12本', '小强:100本')
print(line)
new_data += line
with open('C:\\Users\\EDZ\\Desktop\\test.txt', 'w', encoding = 'utf-8') as file:
file.write(new_data)
#with open('C:\\Users\\EDZ\\Desktop\\test.txt', 'w', encoding = 'utf-8') as file:
# file.write(new_data)
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