制作文件备份 打开原文件 old_f_name = input(“请输入备份的文件路径:”) old_f = open(old_f_name, “r”) 打开新文件 new_f_name = “[复件]” + old_f_name 123.txt -> 123[复件].txt 123 + “[复件]” + .txt index = old_f_name.rfind(“.”) # 获取.对应的后缀 if index >= 0: # 如果有后缀 new_f_name = old_f_name[:index] + “[复件]” + old_f_name[index:] else: