如何将数据格式从 python 更改为 JSON?
Python脚本:
progress = {'user': '170', 'user2': '220'}
level = {'user': '10', 'user2': '14'}
if progress.has_key('user'):
a = progress['user']
b = level['user']
c = json('event': 'data', 'name': 'user', 'progress': a, 'level': b)
self.send(net, c)
Javascript脚本:
var a = JSON.parse(c);
var user = a.user;
var progress = a.progress;
var level = a.level;