我一直在努力从我创建的模块中导入字典。我有模块testmodule1.py,其中定义了字典:
main = {}
main['run_length'] = 1
main['dtt'] = 30
main['nforcing'] = 12
然后在主脚本上,然后导入模块,并想使用键访问值:
import testmodule1
print(testmodule1.main('dtt'))
但是我得到了错误:
Traceback (most recent call last):
File "/Users/gerard/PycharmProjects/BOATSpy/main.py", line 9, in <module>
print(testmodule1.main('dtt'))
TypeError: 'dict' object is not callable
对我在做什么错有任何想法吗?