【发布时间】:2016-07-29 03:04:15
【问题描述】:
这可能是一个愚蠢的问题,但我一生都无法弄清楚 请原谅我令人困惑的变量命名。如果有人能告诉我为什么会发生以下错误和/或我的代码中的任何其他错误,我会欣喜若狂。
JSON:错误的属性名称第 1 行第 2 列(字符 1)
import json
import twitter
a = twitter.get_account("@Suppert2")
q = "cxdffcfctftcvft"
ac = twitter.search(a,q, count=1, parameters=None)
abg = str(ac)
print (abg)
ah = json.loads(abg) # here is where the error is occurring
print ah["completed_in"]
当您打印 abg 时,它会显示为:
{u'search_metadata': {u'count': 1, u'completed_in': 0.048, u'max_id_str': u'718234026394443782', u'since_id_str': u'0', u'refresh_url': u'?since_id=718234026394443782&q=x597567654dfv&include_entities=1', u'since_id': 0, u'query': u'x597567654dfv', u'max_id': 718234026394443782L}, u'statuses': []}
【问题讨论】: