Python twitterapi流不是以tweet对象的形式传递tweet,而是以字符串的形式传递tweet

Python twitterapi流不是以tweet对象的形式传递tweet,而是以字符串的形式传递tweet,python,twitter,Python,Twitter,这就是我希望我的听众做的一个例子。我只想打印传递的tweet的文本,但在尝试打印时,我遇到以下错误: class TwitterListener(StreamListener): def __init__(self): pass def on_data(self, data): print(data.text) 显然,我的tweet是作为字符串而不是tweet对象传递的。我仍然可以打印整个数据,它会像预期的那样(像一个对象)输出数据,但实际上

这就是我希望我的听众做的一个例子。我只想打印传递的tweet的文本,但在尝试打印时,我遇到以下错误:

class TwitterListener(StreamListener):

    def __init__(self):
        pass

    def on_data(self, data):
        print(data.text)
显然,我的tweet是作为字符串而不是tweet对象传递的。我仍然可以打印整个数据,它会像预期的那样(像一个对象)输出数据,但实际上它只是一个看起来像对象的字符串

{“created_at:“Thu Apr 18 11:44:42+0000 2019”,“id:”1118842788160921600,“id_str:”1118842788160921600”,“text:”RT@LCARS\U 24:唐纳德·特朗普的伟大幻想\n他焦虑地梦想:\n \“耗尽美国财政部!”\n而不是他面临破产。\nDonald\u2026,“来源”:“\u003ca href=”http:\/\/twitter.com \“rel=”无需关注\“\u003eTwitter Web客户端\u003c\/a\u003e”,“截断”:false,“in_reply_to_status_id”:null,“in_reply_to_status_id_str”:null,“in_reply_to_user_id”:null,“in_reply_to_screen_name”null,“user”:{“id”:1030908792597360640美国马萨诸塞州,url:null,description:“我希望我们有一位热爱美国的美国总统。橙色是新的颜色!\ud83d\udc31\TheResistance。第45天调用25号。\ud83c\uddfa\ud83c\uddf8”,“translator\u type:“none”,“protected”:false,“verified”:false,“followers\u count”:739,“friends\u count”:742,“List\u count”:0,“Favorities\u count”“:24042,“statuses\u count”:25625,“created\u at”:“Sat Aug 18 20:06:24+0000 2018”,“utc\u offset”:null,“时区”:null,“geo\u enabled”:false,“lang”:“en”,“contributors\u enabled”:false,“is\u translator”:false,“profile\u background\u color”:“000000”,“profile\u background\u image\u url”:“http:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png”,“profile\u background\u image\u url\u https:“https:\/\/abs.twimg.com\/images\/theme1\/bg.png”,“profile\u background\u tile”:false,“profile\u link\u color:“981CEB”,“profile\u边栏\u border\u color:“000000”,“profile\u边栏\u fill\u color:”000000”,“profile\u文本\u color:“000000”,“profile\u使用背景\u image\u color:”false,“profile\u图像\u url:”http:\/\/pbs.twimg.com\/profile\u images\/1030913540708814849\/QVRTrBUj\u normal.jpg,“profile\u image\u url\u https:“https:\/\/pbs.twimg.com\/profile\u images\/1030913540708814849\/QVRTrBUj\u normal.jpg”,“profile\u banner\u url:“https:\/\/pbs.twimg.com\/profile\u banners\/1030908792597360\/15350843”,“默认值”假profile\u下面的“:null,“follow\U request\U sent”:null,“notifications”:null},“geo”:null,“坐标”:null,“place”:null,“contributors”:null,“retweetd\U status”:{“created\U at”:“Thu Apr 18 11:31:27+0000 2019”,“id”:1118839453798129665,“id\U str”:“1118839453798129665”,“text”:“Donald Trump的伟大幻想\n他急切地梦想着:\n \“耗尽美国财政部!”\n他面临破产\u2026 https:\/\/t.co\/l2O1k49QUZ,“来源”:“\u003ca href=\”http:\/\/twitter.com\”rel=\”nofollow\“\u003eTwitter Web Client\u003c\/a\u003e”,“truncated”:true,“回复”状态id:“1118837452196573184”,“回复”状态id:“1118837456573184”,“回复”用户id:“回复”id:“回复”用户id:“回复”用户id:“回复id:“13883838388U id:”829977013888782338,“在对屏幕名称的回复中”:“LCARS 24”,“用户”:{“id”:829977013888782338,“id”str:“829977013888782338”,“名称”:“Bill Morris\ud83c\udf0e”,“屏幕名称”:“LCARS 24”,“位置”:null,“url”:null,“说明”:#抵制(resist)抵制(resist)FBR(GetMoneyOut)(绿色新政)(GreenNewDeal)(绿色新政)(medicarefoll)(取消投票(锁定特朗普)(弹劾特朗普)(弹劾2017年2月10日星期五08:55:15+0000,“utc偏移量”:null,“时区”:null,“地理位置启用”:false,“语言”:“恩”,“贡献者启用”:false,“是译者”:false,“配置文件背景颜色”:“000000”,“配置文件背景图像url”:“http:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png”,“配置文件背景图像url”:https:\/\/abs.twimg.com\/images\/theme1\/bg.png,“配置文件背景”tile:false,“配置文件链接颜色”:“000000”,“配置文件侧栏边框颜色”:“000000”,“配置文件侧栏填充颜色”:“000000”,“配置文件文本颜色”:“000000”,“配置文件使用背景图像”:false,“配置文件图像url”:http:\/\/pbs.twimg.com\/profile\u images\/833910755560808448\/kv8iyfQh\u normal.jpg,“profile\u image\u url\u https:“https:\/\/pbs.twimg.com\/profile\u images\/833910755560808448\/kv8iyfQh\u normal.jpg”,“profile\u banner\u url:“https:\/\/pbs.twimg.com\/profile\u banners\/829977013888782338\/1512210973”,“default\u profile\u-false”默认“假profile”下面的“:null,“follow\U request\U sent”:null,“notifications”:null},“geo”:null,“坐标”:null,“place”:null,“contributors”:null,“is\U quote\U status”:false,“extended\U tweet:{”全文“:“唐纳德·特朗普的伟大幻想\n他急切地梦想:\n \“耗尽美国财政!”\n特朗普面临破产。\n特朗普推动分裂,\n空气中充满仇恨的摩擦。\n成为总统,实现他一生的抱负。\n特朗普让它成为“监狱生活”,“显示文本范围”:[0275],“实体”:{“哈希标签”:[],“URL”:[],“用户提及”:[],“符号”:[]},“引用计数”:0,“回复计数”:0,“转发计数”:7,”最喜欢的网址:11,“实体”:{“hashtags”:[],“url”:[{“url”:“https:\/\/t.co\/l2O1k49QUZ”,“扩展url”:“https:\/\/twitter.com\/i\/web\/status\/1118839453798129665”,“显示url”:“twitter.com\/i\/web\/status\/1\u2026”,“索引”:[117140],“用户提及”:“符号”;“favorited:“false”;“retweeted”;“false”;“过滤级”;“low”;“lang”;“,”是“状态”:false,“引用计数”:0,“回复计数”:0,“转发计数”:0,“收藏计数”:0,“实体”:{“标签”:[],“URL”:[],“用户提及”:[{“屏幕名称”:“LCARS”;“名称”:“比尔·莫里斯”\ud83c\udf0e”,“id”:829977013888782338,“id-str”:“8299770138882338”,“索引”:[3,12],“符号”:[],“收藏”:false,“转发计数”:false”,低级别过滤器[}“,”朗“:”恩“,”蒂姆“
  File "test 2.0.py", line 72, in on_data
    print(data.text)
AttributeError: 'str' object has no attribute 'text'