Commit c5fb8236 by BellCodeEditor

save project

parent 0c787d89
Showing with 6 additions and 0 deletions
...@@ -9,3 +9,8 @@ with open("C:\\Users\\Administrator\\Desktop\\test.txt",'a',encoding='utf-8') as ...@@ -9,3 +9,8 @@ with open("C:\\Users\\Administrator\\Desktop\\test.txt",'a',encoding='utf-8') as
file.write('小强:12本') file.write('小强:12本')
file.write('李明:15本') file.write('李明:15本')
with open("C:\\Users\\Administrator\\Desktop\\test.txt",'r',encoding='utf-8') as file: with open("C:\\Users\\Administrator\\Desktop\\test.txt",'r',encoding='utf-8') as file:
for data in file1:
if '小强:12本 ' in data:
data=data.replace('小强:12本','小强:1本')
new_data +=data
print(new_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