数据擦除不一致消息Python

2024-05-19 02:12:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图使用Python从特定的服务器通道中获取不一致的消息

import requests
import json

def retrieve_messages(channelid):
    headers = {
        'authorization': 'enter the authorization code'
        
    }
    # need to make a request to the url
    r = requests.get(
        f'https://discord.com/api/v9/channels/{channelid}/messages', headers=headers)

    # create JSON object
    jsonn = json.loads(r.text)

    # we can now use a for loop on this JSON object
    for value in jsonn:
        print(value, '\n') # new line as well to separate each message


retrieve_messages('channel server id')

我期望在终端中输出消息,但我一直在接收以下输出。 The output that I am getting instead of the messages


Tags: thetoimportjson消息forobjectrequests

热门问题