实现备份文件功能
file_name = input("输入备份的文件: ") postion = file_name.rfind(".") file_name_new = file_name[:postion] + "[附件]" + file_name[postion:] f1 = open(file_name,‘r‘,encoding="UTF-8") f2 = open(file_name_new,"w",encoding="UTF-8") while True: content = f1.read(1024) if len(content) == 0: break f2.write(content) f1.close()f2.close()
时间: 2024-10-06 12:38:29