Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用execfile()函数将文件用作配置文件。该文件只有一堆变量和值。但是当我试图在我的代码中使用它时,它会抛出IOError: [Errno 2] No such file or directory
execfile()
IOError: [Errno 2] No such file or directory
这是我的代码:
dictionary = {} execfile("myConfig.cfg", dictionary)
myConfig.cfg
myConfig.py
dictionary={'data1':'value1','data2':'value2'}
4.导入数据:
from myConfig import dictionary print dictionary