from sys import argv
from os.path import exists
script, from_file, to_file = argv
print "We will copy %s to %s." % (from_file, to_file)
indata = open(from_file).read()
print "The input file is %d bytes long." % len(indata)
print "Does the output file exist? %r" % exists(to_file)
print "Ready, hit enter to continue, CTRL-C to abort."
raw_input()
txt = open(to_file, 'w').write(indata)
print txt.read()
一直显示
AttributeError:'Nonetype'object has no attribute 'read'.