Commit e089dde5 by BellCodeEditor

save project

parent 18015c05
Showing with 12 additions and 7 deletions
......@@ -2,13 +2,19 @@
#a=open(r"C:\Users\EDZ\Desktop\pyt\123.txt",'w',encoding='utf-8')
#a.write('小兰,12本,小丽,11本,李文,9本,张伟,16本')
#a.close()
#with open(r"C:\Users\EDZ\Desktop\pyt\123.txt",'a',encoding='utf-8')as a:
#a.write('小强,12本\n')
#a.write('李明,15本\n')
# with open(r"C:\Users\EDZ\Desktop\pyt\123.txt",'a',encoding='utf-8')as a:
# a.write('小强,12本\n')
# a.write('李明,15本\n')
c=''
with open(r"C:\Users\EDZ\Desktop\pyt\123.txt",'r',encoding='utf-8')as a:
b=a.read()
#for data in b:
if '小强,10本' in b:
if '小强,12本' in b:
print('数据1在')
if '小兰,12本' in b:
print('数据2在')
\ No newline at end of file
c=b.replace('小强,12本','小强,11本')
print(c)
with open(r"C:\Users\EDZ\Desktop\pyt\123.txt",'w',encoding='utf-8')as a:
a.write(c)
print(a)
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