首页 > 解决方案 > & 不支持的操作数类型:python 中的“str”和“bytes”

问题描述

if(msg.topic == "abc" & msg.payload == b'1'):
     print("Loop entered")


TypeEror: unsupported operand types for &: 'str' and 'bytes'

标签: pythonstringpython-3.x

解决方案


and是我们在 Python 中编写连词的方式,所以:

if msg.topic == "abc" and msg.payload == b'1':

推荐阅读