【发布时间】:2018-10-24 14:41:08
【问题描述】:
我目前正在做一个项目,我们决定使用interface 库而不是abc。但是,当我运行我的程序时,会弹出以下错误:
Traceback (most recent call last):
File "runner.py", line 1, in <module>
from exchanges import *
File "/Users/**/Projects/jimmy/characterlib/__init__.py", line 2, in <module>
from exchanges import hitbtc
File "/Users/**/Projects/jimmy/characterlib/soldier.py", line 5, in <module>
class Soldier(implements(ICharacter)):
File "/usr/local/lib/python3.7/site-packages/interface/interface.py", line 490, in implements
if not issubclass(I, Interface):
TypeError: issubclass() arg 1 must be a class
现在我的设置非常基础:
士兵.py:
from interface import implements, Interface
import characterlib.ICharacter as ICharacter
class Soldier(implements(ICharacter)):
I字符:
from interface import Interface
class ICharacter(Interface):
def walk(self): pass
初始化.py:
import characterlib.ICharacter
import characterlib.Soldier
现在您可以看到,设置非常简单,但是我无法让它正常运行。这怎么可能?
有没有人对这个话题有更多的经验?
谢谢。
【问题讨论】: