首页 > 解决方案 > Python 不一致问题 - Adafruit io

问题描述

所以我有一个简单的代码块:

# Import library and create instance of REST client.
from Adafruit_IO import Client, Feed
aio = Client('aio_bleepbloop')

# Get list of feeds.
feeds = aio.feeds()

# Print out the feed names:
for f in feeds:
    print('Feed: {0}'.format(f.name))

dataRoll = aio.receive('diceRoll').value
dataType = aio.receive('diceType').value
print(dataRoll, dataType)

在一台运行 python 3.7.4 的 PC 上运行良好并运行 - 在我运行 3.8.5 的家用 PC 上,我收到此错误:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-10-41fb818ed5ba> in <module>
      1 # Import library and create instance of REST client.
      2 from Adafruit_IO import Client, Feed
----> 3 aio = Client('aio_bleepbloop')
      4 
      5 # Get list of feeds.

TypeError: __init__() missing 1 required positional argument: 'key'

我真的不知道为什么。

标签: pythonpython-3.xadafruitadafruit-circuitpython

解决方案


你可以试试

aio = Client("username", "aio_bloopbloop")

推荐阅读