-2
無法工作不理解這個錯誤exists函數在Python
Traceback (most recent call last):
File "ex4.py", line 6, in <module>
print "does the file exsts %r" % exists(src_file)
File "C:\Python27\lib\genericpath.py", line 26, in exists
os.stat(path)
TypeError: coercing to Unicode: need string or buffer, file found
這是我的文件內容
from sys import argv
from os.path import exists
script,source,desti=argv
src_file=open(source)
data=src_file.read()
print "does the file exists %r" % exists(src_file)
dest_file=open(desti,'r+')
dest_file.write(data)
print dest_file.read()