【发布时间】:2021-12-26 06:39:24
【问题描述】:
公平的警告,我不是程序员,我做这更多是出于爱好。感谢您抽出宝贵时间审阅此内容并提供建议。
我在 python 中有一个列表:[60.0, 0.0, 0.0, 0.0, 347.0, 30.0, 29.0, 1.0] 并且想通过加密发布到 pubnub。我已经设法在不加密的情况下发布。
作品:
msg = {"freq" : modbusRead[0],
"voltage" : modbusRead[1],
"rpm" : modbusRead[2]
}
readSecret = pubnub.publish().channel(CHANNEL).message(msg).pn_async(publish_callback)
不起作用:
msg = {"freq" : modbusRead[0],
"voltage" : modbusRead[1],
"rpm" : modbusRead[2]
}
secretMsg = pubnub.encrypt("RandomCipherKey", msg)
readSecret = pubnub.publish().channel(CHANNEL).message(secretMsg).pn_async(publish_callback)
我收到以下错误:
TypeError:+ 的不支持的操作数类型:“dict”和“bytes”
【问题讨论】:
-
嘿 Rjindner,我来自 PubNub。这看起来不像 PN 错误,但只是搜索了您的错误:"TypeError: unsupported operand type(s) for +: 'dict' and 'bytes" 并且有 an SO thread on this。希望这对你有用。如果没有,请告诉我。
-
总是将完整的错误消息(从单词“Traceback”开始)作为文本(不是截图,不是链接到外部门户)有问题(不是评论)。还有其他有用的信息。