python3中twisted出现NameError: name ‘file’ is not def

问题:File "D:\Python33\lib\site-packages\twisted\python\lockfile.py", line 52, in <
module>
_open = file
NameError: name ‘file’ is not defined
原因:这个问题是因为twisted不支持Python3的原因,Python3没有file内建方法用open来代替
python2x(file(filename[, mode[, bufsize]]) When opening a file, it’s preferable to use open() instead of

invoking this constructor directly. file is more suited to type testing (for example, writing isinstance(f,

file)).)

解决这个问题: 将 _open = file 改为:

try:
     _open = file
except:
     _open = open


参考:http://mojijs.com/2014/04/134219/index.html

你可能感兴趣的:(python3中twisted出现NameError: name ‘file’ is not def)