Commit c7f15af0 by BellCodeEditor

save project

parent 587a25e4
Showing with 40 additions and 3 deletions
import diy
while True:
aba = input("你想写入还是读取呢?注:写入输入'w'读取输入'r'改输入'g''q'退出")
if aba == "w":
diy.zhuijia()
if aba == "r":
diy.duqu()
if aba =="q":
break
if aba == "g":
v = diy.gai()
diy.xie(v)
\ No newline at end of file
# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本' # 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本'
a = open(r"C:\Users\ycl77\Desktop\sfjbnqug.txt","w",encoding="UTF-8") def zhuijia():
a.write("小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本'") while True:
a.close() yonghu = input("用户输入内容")
if yonghu == "q":
break
else:
with open(r"C:\Users\ycl77\Desktop\sfjbnqug.txt","a",encoding="UTF-8") as a:
a.write(yonghu+"\n")
def duqu():
with open(r"C:\Users\ycl77\Desktop\sfjbnqug.txt","r",encoding="UTF-8") as a:
zhi = a.read()
print(zhi)
def gai():
new = ""
gai_new = input("请输入要改的旧值:")
new_1 = input("请输入新的值:")
with open(r"C:\Users\ycl77\Desktop\sfjbnqug.txt","r",encoding="UTF-8") as a:
# print(zhi)
for i in a:
if gai_new in i:
i = i.replace(gai_new,new_1)
new += i
return new
def xie(abab):
with open(r"C:\Users\ycl77\Desktop\sfjbnqug.txt","w",encoding="UTF-8") as a:
a.write(abab)
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