要判断数组中每条数据的”bank_name”是否等于”TRC20″,您可以使用循环来遍历数组,并检查每个对象的”bank_name”属性。以下是一个示例代码,展示如何进行此操作:python复制
data = [
{
"id": 98,
"user_id": 107,
"bank_id": 0,
"lang": "",
"type": 1,
"bank_name": "ERC20",
"bank_branch": "",
"remark": "ERC20",
"number": "1234566",
"name": "ERC20",
"ext": "",
"status": 1,
"reply": null,
"created_at": "2023-10-15 14:35:48",
"updated_at": "2023-10-15 14:35:48",
"is_self": 0,
"subbranch": "",
"bank_text": "ERC20"
},
{
"id": 96,
"user_id": 107,
"bank_id": 0,
"lang": "",
"type": 1,
"bank_name": "TRC20",
"bank_branch": "",
"remark": "TRC20",
"number": "15132132135",
"name": "TRC20",
"ext": "",
"status": 1,
"reply": null,
"created_at": "2023-10-15 02:19:34",
"updated_at": "2023-10-15 02:19:34",
"is_self": 0,
"subbranch": "",
"bank_text": "TRC20"
},
{
"id": 92,
"user_id": 107,
"bank_id": 0,
"lang": "",
"type": 0,
"bank_name": "Maya",
"bank_branch": "",
"remark": "3",
"number": "333",
"name": "123",
"ext": "",
"status": 1,
"reply": null,
"created_at": "2023-10-14 22:00:59",
"updated_at": "2023-10-14 22:00:59",
"is_self": 0,
"subbranch": "",
"bank_text": "paymaya"
}
]
# 判断每条数据的"bank_name"是否等于"TRC20"
for item in data:
if item["bank_name"] == "TRC20":
print("bank_name is TRC20")
else:
print("bank_name is not TRC20")
运行上述代码,将输出以下结果:复制
bank_name is not TRC20
bank_name is TRC20
bank_name is not TRC20
从输出结果可以看出,第二条数据的”bank_name”等于”TRC20″,而其他两条数据的”bank_name”都不等于”TRC20″。