1.上节内容补充 文件的删除和修改: #文件的删除和修改 #文件中全部都要修改 # with open('歌词',encoding='utf-8') as f1,open('歌词.bak','w',encoding='utf-8') as f2: # for line in f1: # new_line = line.replace('呢','呀') # f2.write(new_line) # import os # os.remove('歌词') # os.rename('歌词.bak','…
# with open('小护士班主任',encoding='utf-8') as f,open ('小护士班主任.bak','w',encoding='utf-8')as f2: # for line in f: # if '星儿' in line: # line = line.replace('星儿','阿娇') # #写文件 # f2.write(line) # import os # os.remove('小护士班主任')#删除文件 # os.rename('小护士班主任.bak','小…