Commit 28dbdc1d by BellCodeEditor

auto save

parent 773ac05b
Showing with 11 additions and 8 deletions
with open(r"c:\Users\admin\Desktop\test.txt","w",encoding="uft-8")as file
with open(r"c:\Users\admin\Desktop\test.txt","w",encoding="utf-8") as file:
file.write("小王:12本\n小江:20本\n")
with open(r"c:\Users\admin\Desktop\test.txt","a",encoding="uft-8")as file
with open(r"c:\Users\admin\Desktop\test.txt","a",encoding="utf-8") as file:
file.write("小明:12本\n")
with open(r"c:\Users\admin\Desktop\test.txt","r",encoding="uft-8")as file
a=qwe.read()
print(a)
with open(r"c:\Users\admin\Desktop\test.txt","r",encoding="uft-8")as file
with open(r"c:\Users\admin\Desktop\test.txt","r",encoding="utf-8") as file:
a=file.read()
with open(r"c:\Users\admin\Desktop\test.txt","r",encoding="utf-8") as file:
new_data=""
for data in file:
if"小江,20本"in data:
print("找到了")
if "小王:12本" in data:
data=data.replace("小王:12本","小王:50本")
new_data=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