Python JSON解码仍显示JSON对象

时间:2016-01-14 02:59:44

标签: python arrays json decoding

我正在尝试使用Telegram bot API。我想将JSON对象解码为一个数组,但无论如何我都尝试JSON格式无关紧要......

import urllib.request
import json

#Your Authentication token here
token = "auth_token" 
website = "https://api.telegram.org/bot" + token

update = urllib.request.urlopen(website + "/getUpdates").read()
updateArray = json.loads(update.decode("utf-8"))


print (updateArray)

就像我说的每当我运行这个我得到JSON格式仍然有人知道我做错了什么?对不起我的无知我对编码很新。提前致谢

另外我知道有一些关于json解码问题的线程但是没有一个对我有用。

名叫拿俄米

1 个答案:

答案 0 :(得分:1)

Python的reprlist的{​​{1}}(这是你dict时得到的)看起来非常类似于JSON数组和对象文字(特别是当其他类型都是字符串和数字时)。解析可能正常,你只是不会通过print - ing。

看到它

尝试跑步:

print

如果print(type(updateArray), updateArray) type,您可能做错了或数据投放不正确。但如果它是strlist,你解析得很好;您可以在Python中将其用作dictlist