1 #Copy the file, and the copied file name is xxx[copy].py 2 #Column test.py After copying test[copy].py 3 4 5 #Get the file name 6 old_file = input( ' Enter the file name to be copied: ' ) 7 8 #Read file 9 ofile = open(old_file, ' r ' ) 10 cfile = ofile.read() 11 12 #Create a new file 13 sign = old_file.rfind( ' . ' ) 14 new_file_name = old_file[:sign] + ' [copy] ' +old_file[sign:] #Create a new file with the original name # + [copy] 15 16 #Open a new file 17 new_file = open(new_file_name, ' w ' ) 18 19 #Copy file 20 new_file.write(cfile) 21 22 #Close the file 23 offile.close() 24 new_file.close()