【发布时间】:2017-03-13 16:12:37
【问题描述】:
我要打印
for post in data["data"]:
print post["message"]
但是我设法只运行了这个 也许是因为消息有两行?
**for post in data["data"]:
print post["link"]**
为什么?
提前致谢
{
"data": [
{
"message": "Have you checked out our SPOOKY SALE yet?\nWith X2 your Coin Store Bonus and all the surprises waiting for you, it is THE way to celebrate Halloween!\nSo go ahead, don\u2019t let the black cat get our tongue\u2026 pick up these \ud83d\udc31 FREE COINS \ud83d\udc31 htUNGAW and see what it\u2019s all about!\n~Lucy",
"link": "h760.128874350565152/1165459096906667/?type=3",
"permalink_url": "h/1165459096906667:0",
"created_time": "2016-10-31T12:56:01+0000",
"type": "photo",
"name": "Timeline Photos",
"id": "128874350565152_1165459096906667",
"shares": {
"count": 61
},
"reactions": {
"data": [
],
"summary": {
"total_count": 1257,
"viewer_reaction": "NONE"
【问题讨论】:
-
我不明白你在问什么。
-
您遇到的错误是什么?
-
我在问如何打印消息,它给我的错误是“消息”不在字典中打印“消息” in data[“data”] output=Fasle
-
"message" in data["data"] 只会输出 false,因为 data["data"] 是一个列表,如果您尝试在 data["data"][0] 中使用 'message',你会得到真实的。
-
谢谢!那么为什么这行代码有效呢?对于数据中的帖子[“数据”]:打印帖子[“链接”]