文件的复制
首先需要创建一个需要复制的文件,然后使用以下命令进行文件内容的拷贝
python py程序名.py 需要拷贝的文件名 拷贝文件名
源程序:
from sys import argv
from os.path import exists
script,from_file,to_file = argv
print(f"Copying from {from_file} to {to_file}")
in_file = open(from_file)
indata = in_file.read()
print(f"The input file is {len(indata)} bytes long")
print(f"Dose the output file exists?{exists(to_file)}")
print("Ready,hit RETURN to continue,CTRL-C to abort.")
input()
out_file = open(to_file,'w')
out_file.write(indata)
print("Alright,all done.")
out_file.close()
in_file.close()