我从 Python 开始,现在卡住了。我必须从 .txt 中的长列表中获取关键的“文本”,例如:
{"delete":"status":"id":294512601600258048,"id_str":"294512601600258048","user_id":90681582,"user_id_str":"90681582"}, "timestamp_ms":"1410368494083"}}
和
{
"created_at": "Wed Sep 10 17:01:33 +0000 2014",
"id": 509748524897292288,
"id_str": "509748524897292288",
"text": "@Brenamae_ I WHALE SLAP YOUR FIN AND TELL YOU ONE LAST TIME: GO AWHALE",
"source": "\u003ca href=\"http:\/\/twitter.com\/download\/android\" rel=\"nofollow\"\u003eTwitter for Android\u003c\/a\u003e",
"truncated": false,
"in_reply_to_status_id": 509748106015948800,
"in_reply_to_status_id_str": "509748106015948800",
"in_reply_to_user_id": 242563886,
"in_reply_to_user_id_str": "242563886",
"in_reply_to_screen_name": "Brenamae_",
"user": "id": 175160659,
"id_str": "175160659",
"name": "Butterfly",
"screen_name": "VanessaLilyWan",
"location": "Canada, Montreal",
"url": "http:\/\/instagram.com\/vanessalilywan",
"description": "British youtubers. 'Nuff said.",
"protected": false,
"verified": false,
"followers_count": 118,
"friends_count": 180,
"listed_count": 2,
"favourites_count": 319,
"statuses_count": 10221,
"created_at": "Thu Aug 05 20:03:16 +0000 2010",
"utc_offset": -36000,
"time_zone": "Hawaii",
"geo_enabled": false,
"lang": "en",
"contributors_enabled": false
}
所以我有两种键,据我所知是:
import json
with open('salida_tweets.txt') as f:
for line in f:
texto=json.loads(line)
objetos=texto.get('text')
print(objetos)
没有任何
@Brenamae_ 我拍拍你的鳍并告诉你最后一次:去AWHALE
但是在打印中,第一个仍然显示为“无”,我需要干净的文本将其与另一个文件混合。
有人能帮我吗?
九州编程
互换的青春
相关分类