[“{\”contributors \“:null,\”truncated \“:false,\”text \“:\”RT @itisprashanth:所有关于#jallikattu的请愿明天将由最高法院审理。明天将是所有青年的D日\ u226 \“}”]
答案 0 :(得分:2)
使用 json 模块将字符串转换为json对象。
<强>实施例强>
import json
h = ["{\"contributors\": null, \"truncated\": false, \"text\": \"RT @itisprashanth: All petitions regarding #jallikattu to be heard by Supreme Court tomorrow. Tomorrow will be the D-Day for all the Youth\u2026\"}"]
for i in h:
v = json.loads(i)
print v["text"]
<强>输出:强>
RT @itisprashanth: All petitions regarding #jallikattu to be heard by Supreme Court tomorrow. Tomorrow will be the D-Day for all the Youth…
答案 1 :(得分:1)
将字符串(给定数组的第一个元素)解析为JSON对象,并获取其文本值。
import json
arr = ["{"contributors": null, "truncated": false, "text": "RT @itisprashanth: All petitions regarding #jallikattu to be heard by Supreme Court tomorrow. Tomorrow will be the D-Day for all the Youth\u2026"}"]
print(json.loads(arr[0])["text"])
# "RT @itisprashanth: All petitions regarding #jallikattu to be heard by Supreme Court tomorrow. Tomorrow will be the D-Day for all the Youth\u2026"