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…
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"
使用json模块将字符串转换为json对象。你知道吗
例如:
输出:
只需将字符串(给定数组的第一个元素)解析为JSON对象,并获取其文本值。你知道吗
相关问题 更多 >
编程相关推荐