我正试图用Micropython编写一个类,它需要用一个参数初始化,但是我很难弄清楚怎么做。你知道吗
我在micropython1.9.4中使用XBee模块
我是这样声明这个类的:
class myClass:
def __init__(self, myArgument):
self.classVar = myArgument
但是当我尝试像这样初始化我的类时:
c = myClass(argumentValue)
我得到这个错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: function takes 1 positional arguments but 2 were given
我做错什么了?你知道吗
在引用classVar
之前是否需要声明它?你知道吗
我能够找到错误,我注意到我在代码的其他地方定义了另一个__init__
方法,它没有收到任何参数。你知道吗
你看过documentation about Python Object Creation吗?你知道吗
相关问题 更多 >
编程相关推荐