Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Can';t从Json中提取一个值_Python_Json_Python 3.x_Python 3.4_Telegram - Fatal编程技术网

Python Can';t从Json中提取一个值

Python Can';t从Json中提取一个值,python,json,python-3.x,python-3.4,telegram,Python,Json,Python 3.x,Python 3.4,Telegram,因此,我正在使用TelegramAPI提供的JSON。我正在尝试将消息值转换为字符串 这是我的Json { "ok": true, "result": [ { "update_id": 855636291, "message": { "message_id": 71, "from": { "id": 1337,

因此,我正在使用TelegramAPI提供的JSON。我正在尝试将消息值转换为字符串

这是我的Json

{
    "ok": true,
    "result": [
        {
            "update_id": 855636291,
            "message": {
                "message_id": 71,
                "from": {
                    "id": 1337,
                    "first_name": "*",
                    "last_name": "*",
                    "username": "*"
                },
                "chat": {
                    "id": 1337,
                    "first_name": "*",
                    "last_name": "*",
                    "username": "*"
                },
                "date": 1435987802,
                "text": "Testing"
            }
        }
    ]
    }
我试图使用的代码来获取值。(使用请求btw)

但是,它不起作用。我设法用
content['result'][0]['update\u id']
检索
update\u id
,但我不知道如何检索
文本


提前谢谢

消息
不是列表,
文本
是其中的一个直接键:

msg = content['result'][0]['message']['text']

删除
['message']
之后的
[0]

msg = content['result'][0]['message']['text']

这里的
message
是一个字典,
text
是该字典中的一个键。只需像在字典中一样访问
text

content['result'][0]['message'][“text”]
msg = content['result'][0]['message']['text']