【发布时间】:2015-04-22 03:57:21
【问题描述】:
from sys import argv
from os.path import exists
script, from_file, to_file = argv
print "Copying from %s to %s" % (from_file, to_file)
in_file = open(from_file, 'w')
print "The input file is %d bytes long" % len(in_file)
print "Does the output file exist? %r" % exists(to_file)
print "Ready, hit RETURN to continue, CTRL-C to abort."
raw_input()
out_file = open(to_file, 'w')
out_file.write(in_file)
print "Alright, all done."
out_file.close()
in_file.close()
我得到的错误 TypeError: 'file' 类型的对象没有 len()
我已将 in_file 变量设置为写入模式,所以我不明白问题出在哪里。
【问题讨论】:
-
如果你说它是重复的,也许可以发送一个链接到“重复”并回答问题?
-
链接在问题的顶部。
标签: python