基本上,我想返回这个JSON数据中的所有“ID”值,并将它们放入一个列表中:
https://www.roblox.com/games/getgameinstancesjson?placeId=70501379&startindex=0
这是我目前掌握的密码。它返回上面的所有JSON数据并将其放入字典中。问题是,我完全不知道如何进入字典并获取ID值这是个怪物。请帮忙。你知道吗
import urllib, json
url = "https://www.roblox.com/games/getgameinstancesjson?
placeId=70501379&startindex=0"
response = urllib.urlopen(url)
data = json.loads(response.read())
您需要遍历JSON数据结构来收集所有id。你知道吗
所以基本上,你是在尝试累积所有当前玩家的ID。你知道吗
这些当前玩家共有7个集合共享,下面是@wiludsdaman答案的显式版本
如果你更勇敢,你可以使用双列表理解来压缩上面的代码
相关问题 更多 >
编程相关推荐