Commit 54890483 by BellCodeEditor

save project

parent 6082eaa6
Showing with 7 additions and 2 deletions
new_data=''
with open(r"C:\Users\tyzhang\Desktop\text.txt",'r',encoding='utf-8') as text: with open(r"C:\Users\tyzhang\Desktop\text.txt",'r',encoding='utf-8') as text:
# text.write('小强:10本\n') # text.write('小强:10本\n')
#text.write('小丽:11本\n') #text.write('小丽:11本\n')
...@@ -5,5 +6,9 @@ with open(r"C:\Users\tyzhang\Desktop\text.txt",'r',encoding='utf-8') as text: ...@@ -5,5 +6,9 @@ with open(r"C:\Users\tyzhang\Desktop\text.txt",'r',encoding='utf-8') as text:
#text.write('张伟:16本\n') #text.write('张伟:16本\n')
for i in text: for i in text:
if'小强:10本'in text: if'小强:10本'in text:
print('数据在文件中') data=data.replace('小强:10本'='小强:11本')
with open(r"C:\Users\tyzhang\Desktop\text.txt",'w',encoding='utf-8') as text:
text.write(new_data)
with open(r"C:\Users\tyzhang\Desktop\text.txt",'r',encoding='utf-8') as text:
a=text.reat()
print(a)
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