Python-没有空格的json [英] Python - json without whitespaces
本文介绍了Python-没有空格的json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚意识到json.dumps()
在JSON对象中添加空格
I just realized that json.dumps()
adds spaces in the JSON object
例如
{'duration': '02:55', 'name': 'flower', 'chg': 0}
如何删除空格以使JSON更紧凑并保存要通过HTTP发送的字节?
how can remove the spaces in order to make the JSON more compact and save bytes to be sent via HTTP?
例如:
{'duration':'02:55','name':'flower','chg':0}
推荐答案
json.dumps(separators=(',', ':'))
这篇关于Python-没有空格的json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文