Commit a6f7a6ca by BellCodeEditor

save project

parent 19d41ab0
Showing with 4 additions and 3 deletions
...@@ -11,14 +11,14 @@ new_data='' ...@@ -11,14 +11,14 @@ new_data=''
# print('小强数据在文件中') # print('小强数据在文件中')
#if'小兰:12'in data: #if'小兰:12'in data:
#print('小兰数据在文件中') #print('小兰数据在文件中')
with open(r"C:\Users\dell\Desktop\新建文本文档 (2).txt",'a',encoding='utf-8')as file1: with open(r"C:\Users\dell\Desktop\新建文本文档.txt",'a',encoding='utf-8')as file1:
for data in file1: for data in file1:
if'小强: 10本'in data: if'小强: 10本'in data:
data=data.replace('小强: 10','小强:11') data=data.replace('小强: 10','小强:11')
if'小兰: 12本'in data: if'小兰: 12本'in data:
data=data.replace('小兰: 12','小兰:14') data=data.replace('小兰: 12','小兰:14')
with open(r"C:\Users\dell\Desktop\新建文本文档 (2).txt",'a',encoding='utf-8')as file1: with open(r"C:\Users\dell\Desktop\新建文本文档.txt"='utf-8')as file1:
file1.write(new_data) file1.write(new_data)
with open(r"C:\Users\dell\Desktop\新建文本文档 (2).txt",'a',encoding='utf-8')as file1: with open(r"C:\Users\dell\Desktop\新建文本文档.txt",'a',encoding='utf-8')as file1:
a=file1.read() a=file1.read()
print(a) print(a)
\ 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