Commit ae37aa99 by BellCodeEditor

save project

parent a8d02629
with open("C:\\Users\\MAKCOO-01\\Desktop\\新建文件夹\\book.txt","r",encoding="utf-8") as file:
for data in file:
if"小强:10"in data:
print("小强数据在文件中")
if"小兰:10"in data:
print("小兰数据在文件中")
a=""
with open("C:\\Users\\MAKCOO-01\\Desktop\\新建文件夹\\book.txt","r",encoding="utf-8") as file:
for data in file:
if"小强:10"in data:
data=data.replace("小强:10","小强:11")
a+=data
with open("C:\\Users\\MAKCOO-01\\Desktop\\新建文件夹\\book.txt","w",encoding="utf-8") as file:
file.write(a)
with open("C:\\Users\\MAKCOO-01\\Desktop\\新建文件夹\\book.txt","r",encoding="utf-8") as file:
q=file.read()
print(q)
\ No newline at end of file
with open("C:\\Users\\MAKCOO-01\\Desktop\\新建文件夹\\book.txt","a",encoding="utf-8") as file:
file.write("小强:16\n")
file.write("李明:16\n")
\ No newline at end of file
#"C:\Users\MAKCOO-01\Desktop\新建文件夹\捐赠明细"
file=open("C:\\Users\\MAKCOO-01\\Desktop\\新建文件夹\\book.txt","w",encoding="utf-8")
file.write("小兰:12\n")
file.write("小丽:11\n")
file.write("李文:9\n")
file.write("张伟:16\n")
file.close()
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