运行我的脚本时收到以下错误:
Traceback (most recent call last):
File "HC_Main.py", line 54, in <module>
setup_exists = os.path.isfile(config_file)
AttributeError: 'function' object has no attribute 'isfile'
示例代码是:
import os
setup_exists = os.path.isfile(setup_exists)
if setup_exists is False:
print "Setup file exists"
当我检查 IDLE 控制台时dir(os.path)
,isfile
列出了。另外,我也可以在 IDLE 中使用该功能而不会出现问题。
会不会是我的 IDE 造成的问题?我也尝试在 IDE 之外运行脚本,但它仍然收到错误。