Commit 835ca3e7 by BellCodeEditor

auto save

parent a6b7f519
Showing with 38 additions and 2 deletions
# 写入同学们的捐赠明细:
file=open(r'C:\Users\29018\Desktop\test.txt','w',encoding='utf-8')
file.write('小兰:12本')
file=open('C:\\Users\\29018\\Desktop\\test.txt','w',encoding='utf-8')
file.write('他用户\n')
file.close()
file=open('C:\\Users\\29018\\Desktop\\test.txt','r',encoding='utf-8')
q=file.read()
print(q)
file.close()
with open('C:\\Users\\29018\\Desktop\\test.txt','r',encoding='utf-8') as file:
for i in file:
if "他" in i:
print("数据在文件里面")
file=open('C:\\Users\\29018\\Desktop\\test.txt','r',encoding='utf-8')
new_data=""
for data in file:
if "他" in data:
data1=data.replace("他","台湾")
new_data=new_data+data1
file=open('C:\\Users\\29018\\Desktop\\test.txt','w',encoding='utf-8')
file.write(new_data)
print(new_data)
file.close()
\ No newline at end of file
file=open('C:\\Users\\29018\\Desktop\\test.txt','w',encoding='utf-8')
file.write('系的很多男生对女生的哪些技能计算机')
file.close()
file=open('C:\\Users\\29018\\Desktop\\test.txt','a',encoding='utf-8')
file.write("dkdmsss")
file.close()
file=open('C:\\Users\\29018\\Desktop\\test.txt','r',encoding='utf-8')
a=file.readlines()
print(a)
\ 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