Python 获取列表中可用的自由余额
json数据来自使用ccxt的远程服务器 我如何才能在其中获得“NEO”的当前平衡Python 获取列表中可用的自由余额,python,python-3.x,list,Python,Python 3.x,List,json数据来自使用ccxt的远程服务器 我如何才能在其中获得“NEO”的当前平衡 def检查余额(符号): balance=exchange.fetch\u balance() sonuc=余额['info']['balances'] 打印(类型(sonuc)) 返回支票余额 类型=列表 [ {'asset':'BTC','free':'0.00000000','locked':'0.00000000'}, {'asset':'LTC','free':'0.00000000','locked
def检查余额(符号):
balance=exchange.fetch\u balance()
sonuc=余额['info']['balances']
打印(类型(sonuc))
返回支票余额
类型=列表
[
{'asset':'BTC','free':'0.00000000','locked':'0.00000000'},
{'asset':'LTC','free':'0.00000000','locked':'0.00000000'},
{'asset':'ETH','free':'0.00000000','locked':'0.00000000'},
{'asset':'NEO','free':'0.00000000','locked':'0.00000000'}
]
循环浏览列表并搜索近地天体
def find_asset(asset_str, asset_list):
for asset in asset_list:
if asset['asset'] == asset_str:
return asset
print(find_asset("NEO", my_list))
大概是这样的:
for i in sonuc:
if i['asset'] == 'NEO':
print(i['free'],i['locked'])
这里有一行
neo_balance = next((sub for sub in source if sub['asset'] == 'NEO'), None)