Python 我如何得到这个值的东西?

Python 我如何得到这个值的东西?,python,arrays,list,python-requests,Python,Arrays,List,Python Requests,我很抱歉,如果这看起来像一个混乱,但我是混乱的python请求 s=requests.Session() search=s.get(“https://www.roblox.com/search/users/results?keyword=roblox&maxRows=12&startIndex=01.内容 soup=BeautifulSoup(搜索,'html.parser') 印花(汤) 所以,当我打印soup时,它打印了那个,我不知道它打印的是什么类型的东西,我想知道的是如何访问这个数组中

我很抱歉,如果这看起来像一个混乱,但我是混乱的python请求

s=requests.Session()
search=s.get(“https://www.roblox.com/search/users/results?keyword=roblox&maxRows=12&startIndex=01.内容
soup=BeautifulSoup(搜索,'html.parser')
印花(汤)
所以,当我打印soup时,它打印了那个,我不知道它打印的是什么类型的东西,我想知道的是如何访问这个数组中的列表,特别是第一个,有

{"Keyword":"roblox","StartIndex":0,"MaxRows":12,"TotalResults":10000,"UserSearchResults":[{"UserId":1,"Name":"ROBLOX","DisplayName":"ROBLOX","Blurb":"Welcome to the Roblox profile! This is where you can check out the newest items in the catalog, and get a jumpstart on exploring and building on our Imagination Platform. If you want news on updates to the Roblox platform, or great new experiences to play with friends, check out blog.roblox.com. Please note, this is an automated account. If you need to reach Roblox for any customer service needs find help at www.roblox.com/help","PreviousUserNamesCsv":"","IsOnline":false,"LastLocation":null,"UserProfilePageUrl":"/users/1/profile","LastSeenDate":null,"PrimaryGroup":"","PrimaryGroupUrl":""},{"UserId":7504,"Name":"Dragon Roblox","DisplayName":"Dragon Roblox","Blurb":"","PreviousUserNamesCsv":"","IsOnline":false,"LastLocation":null,"UserProfilePageUrl":"/users/7504/profile","LastSeenDate":null,"PrimaryGroup":"","PrimaryGroupUrl":""},{"UserId":5401,"Name":"Alpha Roblox","DisplayName":"Alpha Roblox","Blurb":"","PreviousUserNamesCsv":"","IsOnline":false,"LastLocation":null,"UserProfilePageUrl":"/users/5401/profile","LastSeenDate":null,"PrimaryGroup":"","PrimaryGroupUrl":""},{"UserId":2257,"Name":"roblox alpha test","DisplayName":"roblox alpha test","Blurb":"[ Content Deleted ]","PreviousUserNamesCsv":"","IsOnline":false,"LastLocation":null,"UserProfilePageUrl":"/users/2257/profile","LastSeenDate":null,"PrimaryGroup":"","PrimaryGroupUrl":""},{"UserId":477673841,"Name":"roblox_new5","DisplayName":"roblox_new5","Blurb":"","PreviousUserNamesCsv":"","IsOnline":false,"LastLocation":null,"UserProfilePageUrl":"/users/477673841/profile","LastSeenDate":null,"PrimaryGroup":"","PrimaryGroupUrl":""},{"UserId":477457467,"Name":"ROBLOX_REDPRO","DisplayName":"ROBLOX_REDPRO","Blurb":"","PreviousUserNamesCsv":"","IsOnline":false,"LastLocation":null,"UserProfilePageUrl":"/users/477457467/profile","LastSeenDate":null,"PrimaryGroup":"","PrimaryGroupUrl":""},{"UserId":476078112,"Name":"robloxbombboy","DisplayName":"robloxbombboy","Blurb":"","PreviousUserNamesCsv":"","IsOnline":false,"LastLocation":null,"UserProfilePageUrl":"/users/476078112/profile","LastSeenDate":null,"PrimaryGroup":"","PrimaryGroupUrl":""},{"UserId":470927030,"Name":"robloxXpertPRo","DisplayName":"robloxXpertPRo","Blurb":"","PreviousUserNamesCsv":"","IsOnline":false,"LastLocation":null,"UserProfilePageUrl":"/users/470927030/profile","LastSeenDate":null,"PrimaryGroup":"","PrimaryGroupUrl":""},{"UserId":474924046,"Name":"ROBLOXF4KE","DisplayName":"ROBLOXF4KE","Blurb":"","PreviousUserNamesCsv":"","IsOnline":false,"LastLocation":null,"UserProfilePageUrl":"/users/474924046/profile","LastSeenDate":null,"PrimaryGroup":"","PrimaryGroupUrl":""},{"UserId":471446101,"Name":"robloxplayer12474","DisplayName":"robloxplayer12474","Blurb":"","PreviousUserNamesCsv":"","IsOnline":false,"LastLocation":null,"UserProfilePageUrl":"/users/471446101/profile","LastSeenDate":null,"PrimaryGroup":"","PrimaryGroupUrl":""},{"UserId":476443526,"Name":"robloxgio2009","DisplayName":"robloxgio2009","Blurb":"","PreviousUserNamesCsv":"","IsOnline":false,"LastLocation":null,"UserProfilePageUrl":"/users/476443526/profile","LastSeenDate":null,"PrimaryGroup":"","PrimaryGroupUrl":""},{"UserId":476338383,"Name":"Roblox00118","DisplayName":"Roblox00118","Blurb":"","PreviousUserNamesCsv":"","IsOnline":false,"LastLocation":null,"UserProfilePageUrl":"/users/476338383/profile","LastSeenDate":null,"PrimaryGroup":"","PrimaryGroupUrl":""}]}

我确信这不是请求问题,只是某种python数组问题。

由于响应是JSON,您可以使用Requests
response.JSON()
方法对其进行解析:

[{'UserId':1, 'Name':"ROBLOX"}]
您的数据是。您可以使用以下方法将其转换为python字典:

然后,您可以通过以下方式访问第一个用户:

import json
users = json.loads(soup)
输出(用于示例数据):


看起来您想知道如何解析UserSearchResults?你看过吗
import json
users = json.loads(soup)
print(users['UserSearchResults'][0])
{
 'UserId': 1,
 'Name': 'ROBLOX',
 'DisplayName': 'ROBLOX',
 'Blurb': 'Welcome to the Roblox profile! This is where you can check out the newest items in the catalog, and get a jumpstart on exploring and building on our Imagination Platform. If you want news on updates to the Roblox platform, or great new experiences to play with friends, check out blog.roblox.com. Please note, this is an automated account. If you need to reach Roblox for any customer service needs find help at www.roblox.com/help',
 'PreviousUserNamesCsv': '',
 'IsOnline': False,
 'LastLocation': None,
 'UserProfilePageUrl': '/users/1/profile',
 'LastSeenDate': None,
 'PrimaryGroup': '',
 'PrimaryGroupUrl': ''
}