python - & 不支持的操作数类型:python 中的“str”和“bytes”
问题描述
if(msg.topic == "abc" & msg.payload == b'1'):
print("Loop entered")
TypeEror: unsupported operand types for &: 'str' and 'bytes'
解决方案
and
是我们在 Python 中编写连词的方式,所以:
if msg.topic == "abc" and msg.payload == b'1':
推荐阅读
- javascript - 包全局配置 NPM 库
- operating-system - 计算机 CPU 如何执行软件应用程序
- progressive-web-apps - 使用 workbox-cli 设置 service worker 后应该将哪些文件添加到版本控制中
- r - 使用 RSelenium 寻找灵活的元素
- c# - 将 Polly 与 EF Core 3.1 一起使用
- google-cloud-platform - Google Cloud API 凭据消失了
- multithreading - gRPC Java 客户端能否通过长期存在的 gRPC 流并行发送多个请求以及如何管理 N 个流
- html - 背景图像不透明度 - 在 CSS 中
- java - 在java中通过调度函数更新的访问变量
- python - 在 macOS Big Sur 11.3.1 上安装 lxml 3.8.0 时出错