from sys import argv from os.path import exists #又import了一个命令exists,这个命令将文件名字符串作为参数,如果文件存在返回TRUE,否则返回FALSE script,from_file,to_file=argv #传参,不过没有管exists哎 print("copying from %s to %s "%(from_file,to_file)) #打印copying from "from_file"to "to_file" get=open(from_file) #打开“from_file”并传递给对象get indata=get.read() #读文件然后传给indata print("the input file is %d bytes long"%len(indata)) #打印the input file is “一个数字”bytes long print("does the output file exist?%r"%exists(to_file)) #打印does the output file exist?+true/false(有就是true) print("ready,hit RETURN to continue ,CTRL-C to abort.") #打印ready,hit RETURN to continue ,CTRL-C to abort. input('<') #一个提示符 output=open(to_file,'w') #以只写的模式打开“to_file” output.write(indata) #把indata里的内容(from_file)写进output(to_file) print("alright,all done") #打印alright,all done output.close() #关闭output get.close() #关闭get copied=open("copied.txt") print(copied.read()) #查看文件咯