Commit c62d45dd by BellCodeEditor

save project

parent 149c1413
Showing with 12 additions and 7 deletions
new_data=''
with open('C:\\Users\\yong'hu\\Desktop\\book.text',"r",encoding='utf-8')as fillel: with open('C:\\Users\\yong'hu\\Desktop\\book.text',"r",encoding='utf-8')as fillel:
for data in fillel: for data in fillel:
print('小强在文件中') if'小强:10'in data:
if data=data.replace('小强:10','小强':12本)
print('小强在文件中') if'小兰:12'in data:
if'小兰:12'in data: data=data.replace('小兰:12',‘小兰:14本)
print('小兰在文件中') new_data+=data
\ No newline at end of file with open('C:\\Users\\yong'hu\\Desktop\\book.text',"w",encoding='utf-8')as fillel:
fillel.write(new_data)
with open('C:\\Users\\yong'hu\\Desktop\\book.text',"r",encoding='utf-8')as fillel:
a=fillel.read
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