[英]How to go about storing users data in Json
I have been messing with Json a bit today and doing some trial and error but I couldn't seem to make this work: 我今天一直在和Json搞混,并做了一些试验和错误,但是我似乎无法完成这项工作:
def checkForNewBooty(chan):
j = urllib2.urlopen('http://tmi.twitch.tv/group/user/' + chan + '/chatters')
j_obj = json.load(j)
viewers = j_obj['chatters']['viewers']
moderators = j_obj['chatters']['moderators']
for x in viewers and moderators:
print(json.dumps('users' = {'johhny' = {'Points' = 0, 'Time Joined' = 9938}}))
Json example of what I'm trying to do: 我想要做的Json示例:
{
users = {
"johhnyknoxville"
}
}
What is the proper way of doing this? 正确的做法是什么?
Python dictionaries (which are serialized using JSON) use :
and not =
. Python字典(使用JSON序列化)使用:
而不是=
。
Try: 尝试:
json.dumps({'users': {'johhny': {'Points': 0, 'Time Joined': 9938}}})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.