Commit eb5a27bc by BellCodeEditor

auto save

parent 59f687ca
Showing with 25 additions and 0 deletions
# file=open(r'c:\Users\Administrator\Desktop\book.txt','w',encoding='utf-8')
# file.write("小兰:12本\n") # XIAO LAN BEN
# file.write("小丽:11本\n") # LI
# file.write("李文:9本\n") # LI WEN
# file.write("张伟:16本\n") # ZHANG WEI
# file.close()
with open(r'c:\Users\Administrator\Desktop\book.txt','w',encoding='utf-8') as file:
file.write("小强:12本\n") # XIAO QIANG BEN
file.write("李明:12本\n") # LI MING
# with open(r'c:\Users\Administrator\Desktop\book.txt','r',encoding='utf-8') as file:
# a=file.read()
# print(a)
with open(r'c:\Users\Administrator\Desktop\book.txt','r',encoding='utf-8') as file:
for data in file:
if "小强:12本" in data:
print("数据在文件中") # SHU JU ZAI WEN JIAN ZHONG
\ No newline at end of file
# 修改文件中的内容:序列名.replace(旧,新)
str="我有一个苹果"
print(str.replace("一","三"))
new_data+=data
new_data=new_data+data
i=i+1 i+=1
\ 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