python MQTT 出现TypeError: payload must be a string, bytearray, int, float or None.
原因, MQTT 发布信息,是不能发布 对象的,只能发布 字符串,整形,浮点型这样的
解决方法
self.__mqtt__.publish("computex/iot/5100/DataTransfer", json.dumps(send_msg))
// 将 json 的字典转换成字符串。
python MQTT 出现TypeError: payload must be a string, bytearray, int, float or None.的更多相关文章
- python import 错误 TypeError: 'module' object is not callable
python import 错误 TypeError: 'module' object is not callable 在这里,有 Person.py test.py; 在 test.py 里面 im ...
- TypeError: coercing to Unicode: need string or buffer, ChatRoom found
在用django框架中遇到一个错误,是模型编写中出的错误 TypeError: coercing to Unicode: need string or buffer, ChatRoom found 解 ...
- [转载] Python 列表(list)、字典(dict)、字符串(string)常用基本操作小结
创建列表 sample_list = ['a',1,('a','b')] Python 列表操作 sample_list = ['a','b',0,1,3] 得到列表中的某一个值 value_star ...
- Python 列表(list)、字典(dict)、字符串(string)常用基本操作小结
创建列表 sample_list = ['a',1,('a','b')] Python 列表操作 sample_list = ['a','b',0,1,3] 得到列表中的某一个值 value_star ...
- TypeError: sequence item 1: expected str instance, int found
Error Msg Traceback (most recent call last): File "E:/code/adva_code/my_orm.py", line 108, ...
- TypeError: sequence item 0: expected string, Tag found
原始代码: soup = BeautifulSoup(result, 'html.parser') content_list = soup.find_all('p', attrs={"cla ...
- java和python中的string和int数据类型的转换
未经允许,禁止转载!!! 在平时写代码的时候经常会用到string和int数据类型的转换 由于java和python在string和int数据类型转换的时候是不一样的 下面总结了java和python ...
- Python学习(四)数据结构 —— int float
Python 数字类型 int float 数字常量 int: 一般的整数, long: 长整型,2.x版本需在数字后加 “L” 或 “l” ,表示长整型 如 100000000L: python ...
- python django中使用sqlite3数据库 存储二进制数据ByteArray
在python中使用sqlite3数据库存储二进制流数据ByteArray,在django使用sqlite3数据库时,有时候也要注意最好使用二进制流ByteArray插入字符串. 使用ByteArra ...
随机推荐
- Eclipse Oxygen创建maven web项目(二)
配置项目依赖库及第三方工具. 如示例的pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi ...
- json解析为泛型对象
一.方法 public <T> T jsonToObjByType(String str, Type type) { try { if (isValidJson(str)) { retur ...
- 安装 Vbundle 的笔记
Vbundle 挺好用的,能够很方便管理Vim的一些插件.虽然Vbundle的安装方法看的很简单,但是它的配置却让我弄了很久,现在记录如下,方便后面安装时再出现相同的问题: 我按照这里的官方提示的安装 ...
- java中使用for遍历集合是注意的空指针异常
public static void main(String[] args) { List<Object> a = null; for(Object i : a)//会有空指针异常 { } ...
- laravel5.7的redis配置,一直报错Class 'Predis\Client' not found
laravel5.7的redis配置,一直报错Class 'Predis\Client' not found 首先我检查了配置,和composer 都没有错,用原生的redis也可以正常连接和读写. ...
- 请教Mysql如何删除 不包含 某些字符的记录
删除包含指定字符的记录 delete from `表` where `字段` like '%指定字符1%' or like '%指定字符2%' or like '%指定字符3%' 删除不包含指定字符的 ...
- Nginx(四):压缩功能详解
gzip (GNU-ZIP) 是一种压缩技术.经过 gzip 压缩后页面大小可以变为原来的 30%甚至更小. 这样,用户浏览页面的时候速度会快得多. gzip 的压缩页面需要浏览器和服务器双方都支持 ...
- java正则表达式:验证字符串数字
正则表达式:^([0-9]+)$ -> ^:匹配以0-9开头,[0-9]:匹配0-9数字,+:匹配至少一个数字,$:匹配以数字结尾 /** *正则表达式:验证字符串数字 *两种方式: *1.pa ...
- 安装SQL Server提示“等待数据库引擎恢复句柄失败”
1.如果MSSQLSERVER服务已经启动,则停止. 2.以管理员身份打开命令行,执行命令:"C:\Program Files\Microsoft SQL Server\MSSQL10_50 ...
- Atitit hibernate3 hinernate4 hibernate5新特性attilax总结
Atitit hibernate3 hinernate4 hibernate5新特性attilax总结 1.1. Hibernate3的新特性 1 1.2. hibernate4.1版本中的新特性和h ...