python 中对json的操作
一,需要加载json lib
import json
二、把list转为json格式的字符串
msg = {'clientMAC' : '0000-0000-0001', 'acSN' : '11111111', 'onLineTime' : '2018-12-01 11:06:25'} msgStr = json.dumps(msg)
转完后打印:
>>> msgStr '{"acSN": "11111111", "onLineTime": "2018-12-01 11:06:25", "clientMAC": "0000-0000-0001"}' >>>
三、相关官方API请参考
https://docs.python.org/2/library/json.html