Commit 7d3ae756 by BellCodeEditor

auto save

parent dc22b1a3
Showing with 34 additions and 0 deletions
import random
list=[1,2,3,4,5,6,7]
a=random.choice(list)
print(a)
\ No newline at end of file
file=open(r'C:\Users\29018\Desktop\test.txt','w',encoding='utf-8')
file.write('国庆节快乐')
file.close()
file=open(r'C:\Users\29018\Desktop\test.txt','r',encoding='utf-8')
a=file.read()
print(a)
file.close()
new_data=""
file=open(r'C:\Users\29018\Desktop\test.txt','r',encoding='utf-8')
for i in file:
if '国庆' in i:
new=i.replace('国庆','中秋')
new_data=new_data+new
print(new_data)
\ No newline at end of file
file=open(r'C:\Users\29018\Desktop\test.txt','w',encoding='utf-8')
file.write('国庆节快乐')
file.close()
file=open(r'C:\Users\29018\Desktop\test.txt','r',encoding='utf-8')
a=file.read()
print(a)
file.close()
\ 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