【发布时间】:2017-12-20 05:24:18
【问题描述】:
dir_path = os.path.dirname(os.path.realpath(__file__))
from os.path import isfile, join
onlyfiles = [f for f in listdir(dir_path) if isfile(join(dir_path, f))]
print(onlyfiles);
with open("config.json", 'r') as jsondata:
config = json.loads(jsondata.read())
以某种方式运行此代码会触发一个不存在的错误,尽管该文件在
期间列出print(onlyfiles);
这是控制台的完整输出日志。
Traceback (most recent call last):
['builder.py', 'builder.spec', 'builderloader2.rb', 'config.json',
'Run.bat', 'Run.bat.lnk', 'test.json']
File "C:/Users/cody.jones/Desktop/Builder Generator Release/builder.py",
line 26, in <module>
with open("config.json", 'r') as jsondata:
FileNotFoundError: [Errno 2] No such file or directory: 'config.json'
Process finished with exit code 1
【问题讨论】:
标签: python python-3.x