Chinaunix

标题: NameError: name '__file__' is not defined? [打印本页]

作者: wash    时间: 2006-01-11 11:14
标题: NameError: name '__file__' is not defined?
import os
localDir = os.path.dirname(__file__)
在一个自定义的模块中,thanks.
作者: limodou    时间: 2006-01-11 12:30
内置模块不存在__file__属性。这一点可以看inspect模块。
作者: Northland    时间: 2006-01-11 14:05
import os
localDir = os.path.dirname(__file__)
在python 自带的编辑器中进行调试会提示出错
如果用其他编辑器进行调试没有问题(ultraEdit, Eclipse, or NewEdit (i guess it))
或者直接用命令行运行  python.exe  yourfile.py , 也不会出错
作者: limodou    时间: 2006-01-11 17:45
可以去 python.list 或 google 上查一查好象看到过这样的问题,记不清了。
作者: wash    时间: 2006-01-12 15:20
谢谢limodou northland




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2