# coding=utf-8
from sys import argv
# exists将文件名字符串作为参数,如果文件存在返回True否则False
from os.path import exists
script,from_file,to_file = argv
print("Copying from %s to %s" %(from_file,to_file))
# We could do these two on one line too,how?
in_file = open(from_file).read()
#indata = in_file.read()
print("The input file is %d bytes long" % len(in_file))
print("Does the output file exist? %r" % exists(to_file))
input("Ready,hit RETURN to continue,CTRL-C to abort.>>>")
out_file = open(to_file,'w').write(in_file)
print("Alright,all done.")
#out_file.close()
#in_file.close()
"""
len() 函数的功能是什么?
它会以数字的形式返回你传递的字符串的长度
"""
笨方法学习Python-习题17: 更多文件操作
最新推荐文章于 2020-01-15 15:47:25 发布