你可以使用列表理解来过滤你的结果。In变量
r
你有(我假设)字典列表:
r = [
{
"market_hash_name": "USP-S | Whiteout (Factory New)",
"currency": "EUR",
"suggested_price": 153.1,
"item_page": "https://skinport.com/item/usp-s-whiteout-factory-new",
"market_page": "https://skinport.com/market?item=Whiteout&cat=Pistol&type=USP-S",
"min_price": 171.03,
"max_price": 232.16,
"mean_price": 197.13,
"median_price": 194.25,
"quantity": 7,
"created_at": 1633294586,
"updated_at": 1693686845,
},
{
"market_hash_name": "USP-S | Whiteout (Field-Tested)",
"currency": "EUR",
"suggested_price": 22.18,
"item_page": "https://skinport.com/item/usp-s-whiteout-field-tested",
"market_page": "https://skinport.com/market?item=Whiteout&cat=Pistol&type=USP-S",
"min_price": 19.25,
"max_price": 175,
"mean_price": 41.53,
"median_price": 36.55,
"quantity": 61,
"created_at": 1632899292,
"updated_at": 1693686845,
},
{
"market_hash_name": "USP-S | Whiteout (Minimal Wear)",
"currency": "EUR",
"suggested_price": 32.96,
"item_page": "https://skinport.com/item/usp-s-whiteout-minimal-wear",
"market_page": "https://skinport.com/market?item=Whiteout&cat=Pistol&type=USP-S",
"min_price": 39.64,
"max_price": 185,
"mean_price": 77.81,
"median_price": 69.99,
"quantity": 61,
"created_at": 1632921139,
"updated_at": 1693686845,
},
{
"market_hash_name": "USP-S | Whiteout (Well-Worn)",
"currency": "EUR",
"suggested_price": 17.62,
"item_page": "https://skinport.com/item/usp-s-whiteout-well-worn",
"market_page": "https://skinport.com/market?item=Whiteout&cat=Pistol&type=USP-S",
"min_price": 19.79,
"max_price": 32,
"mean_price": 25.9,
"median_price": 25.9,
"quantity": 2,
"created_at": 1632976633,
"updated_at": 1693686845,
},
{
"market_hash_name": "Valeria Phoenix Pin",
"currency": "EUR",
"suggested_price": 51.74,
"item_page": "https://skinport.com/item/valeria-phoenix-pin",
"market_page": "https://skinport.com/market?item=Valeria%20Phoenix%20Pin&cat=Collectible",
"min_price": 53.95,
"max_price": 80,
"mean_price": 63.66,
"median_price": 59.99,
"quantity": 14,
"created_at": 1535988295,
"updated_at": 1693686845,
},
]
market_hash_name = "Valeria Phoenix Pin"
min_price = 50
out = [
dct
for dct in r
if dct["market_hash_name"] == market_hash_name and dct["min_price"] >= min_price
]
print(out)
打印:
[
{
"market_hash_name": "Valeria Phoenix Pin",
"currency": "EUR",
"suggested_price": 51.74,
"item_page": "https://skinport.com/item/valeria-phoenix-pin",
"market_page": "https://skinport.com/market?item=Valeria%20Phoenix%20Pin&cat=Collectible",
"min_price": 53.95,
"max_price": 80,
"mean_price": 63.66,
"median_price": 59.99,
"quantity": 14,
"created_at": 1535988295,
"updated_at": 1693686845,
}
]