如何在Python中从对象获取数据

2024-05-16 03:41:45 发布

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

我想获取discord.user_id,我对python非常陌生,只需要帮助获取这些数据。 我什么都试过了,网上没有明确的答案。 目前,这用于在属性部分中获取数据点

pledge.relationship('patron').attribute('first_name')

enter image description here


Tags: 数据答案nameid属性attributefirstdiscord
2条回答

你应该试试这个:

import pandas as pd
df = pd.read_json(path_to_your/file.json)

ourput将是一个DataFrame,它是一个矩阵,其中json属性将是列的名称。您必须在之后对其进行操作,这是最好的,因为数据帧上的操作在处理时间方面是优化的

Here是官方文件,看一下

假设整个对象是call myObject,则可以通过调用myObject.json_data.attributes.social_connections.discord.user_id来获取discord.user_id

相关问题 更多 >