我正在嘗試使用來自推特用戶時間線的 Tweepy 輸出。我嘗試過將輸出視為JSON,但無濟于事。以下是我檢索數據的方式,以及處理數據的一些嘗試以及我收到的后續錯誤。我如何檢索數據:user_timeline = api.user_timeline(screen_name='TechCrunch', count=5)部分輸出:[Status(_api=, _json={'created_at': 'Tue Mar 24 18:02:08 +0000 2020', 'id': 1242512035159687169, 'id_str': '1242512035159687169', 'text': 'RT @Yair_Rosenberg: Please listen to...'''嘗試的代碼:Timeline_result = json.loads(user_timeline)錯誤信息:TypeError: the JSON object must be str, bytes or bytearray, not ResultSet嘗試的代碼:Timeline_result = json.dumps(user_timeline)錯誤信息:TypeError: Object of type Status is not JSON serializable我能夠從此數據集中提取任何可讀內容的唯一方法是使用以下方法-user_timeline[0].text部分輸出:'RT @Yair_Rosenberg: Please listen to Dr...'最終,我希望能夠單獨提取所有相關信息,即“id”,“id_str”,“文本”等...謝謝大家的幫助。我已經把頭撞到墻上一段時間了......
兩次輸出問題
慕桂英3389331
2022-09-13 19:49:41