我试图在main.py
的Things
类中,从define.py
定义一个方法(我们称之为hello
)
我当前的代码正在引发AttributeError: module 'runme' has no attribute 'promptMe'
(下面是完整的回溯)
这里是main.py
的代码:
import define
class Things:
def doWhatever():
print("whatever")
这里是define.py
的代码:
import main
def hello():
print("Hello!")
main.Things.hello = hello()
我也尝试过其他的解决方案,比如def main.Things.hello: hello()
和def main.Things.hello: print("Hello!")
,但都不起作用
这是运行define.py
时的回溯:
Traceback (most recent call last):
File "define.py", line 5, in <module>
import main
File "/path/to/main.py", line 9, in <module>
import define
File "/path/to/define.py", line 10, in <module>
main.Things.hello = hello
AttributeError: module 'main' has no attribute 'Things'
所有的帮助将不胜感激。谢谢
目前没有回答
相关问题 更多 >
编程相关推荐