我试图将Discord机器人程序链接到我创建的文本网关,但当我试图调用游戏本身的class时,它告诉我,
AttributeError: module 'code' has no attribute 'Main'
这是我的代码:
# bot.py
import code # Import the code for the actual game
main = code.Main() # Begin the game's processes
# code.py
class Main:
def __init__(self):
self.otherModule() # This module is used to continue the flow throughout the class
我看不出它出了什么问题。当我试图查找它时,我只被告知";给它上一堂课">
重命名code
。模块code
已经作为内置模块存在于Python3中。
Python 3.10.4
Type "help", "copyright", "credits" or "license" for more information.
>>> import code
>>> print(code)
<module 'code' from '/usr/lib/python3.10/code.py'>
来源:https://docs.python.org/3/library/code.html#module-代码