__init_u3;()缺少1个必需的位置参数:“通道”

2024-04-26 05:26:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图从git使用这个:https://github.com/adafruit/Adafruit_CircuitPython_MPR121/blob/master/adafruit_mpr121.py

在它定义的类中:

class MPR121_Channel:

def __init__(self, mpr121, channel):
    self._mpr121 = mpr121
    self._channel = channel

当我运行示例代码时,基于:https://github.com/adafruit/Adafruit_CircuitPython_MPR121/blob/master/examples/mpr121_simpletest.py

但要加上一句话

mpr121_channel = adafruit_mpr121.MPR121_Channel(i2c)

为了访问该类中的变量,它给出了错误:

__init__() missing 1 required positional argument: 'channel'

我编辑成:

mpr121_channel = adafruit_mpr121.MPR121_Channel(i2c, channel)

但现在“通道”的名称尚未定义

请有人能帮我找出在哪里(以及如何)定义频道吗

谢谢大家!


Tags: pyhttpsselfgithubmastercircuitpythonadafruitcom