python如何提取其中tag值为544574871的数据的sid并保存为变量

python如何提取其中tag值为544574871的数据的sid并保存为变量

import requests

import json

url = "https://api.vmlogin.com/v1/profile/list?token=c911b834f024340cf7017743b7b54414"

response = requests.get(url)

s = response.json()

print(s)

s = {

"data": [

{

"sid": "00AC47AA-AFD2-4DF2-A722-939CDFCC9350",

"name": "5D-\u55f7\u55f7\u51fa",

"tag": "544574871",

"lastUsedTime": 1646855643

},

{

"sid": "01BAE161-599B-4506-9A64-AB9CA9EC9700",

"name": "lo8",

"tag": "niki\u5988",

"lastUsedTime": 1646804876

},

{

"sid": "051B3558-F423-414C-BD34-5CE39E2A517A",

"name": "\u6ce8\u518c",

"tag": "Default group",

"lastUsedTime": 0

},

{

"sid": "0BE57EDA-6A32-4416-83E8-0EC0AD78341B",

"name": "KK_3",

"tag": "TB-96151613",

"lastUsedTime": 1647868170

},

{

"sid": "10BE8136-E8A1-40D5-B48B-F63623C0C070",

"name": "cc",

"tag": "544574871",

"lastUsedTime": 1646857532

}

]

}

python如何提取其中tag值为544574871的数据的sid并保存为变量


回答:

data = s["data"]

for item in data:

if item["tag"] == '544574871' :

outSid=item["sid"]

break

print(outSid)


回答:

class Tmp(object):

...

tmp = Tmp()

for item in data.get("data", {}):

if "xxxx" in item.get("tag", ""):

setattr(tmp, "变量名", item.get("tag", ""))

print(dir(tmp))

以上是 python如何提取其中tag值为544574871的数据的sid并保存为变量 的全部内容, 来源链接: utcz.com/p/938378.html

回到顶部