我正在试着从我的Binance账户中拿到我的现货钱包资产的余额。
我尝试过的:
bal = client.get_account()
print(bal)
返回值:
"makerCommission": 15,
"takerCommission": 15,
"buyerCommission": 0,
"sellerCommission": 0,
"canTrade": true,
"canWithdraw": true,
"canDeposit": true,
"balances": [
{
"asset": "BTC",
"free": "4723846.89208129",
"locked": "0.00000000"
},
{
"asset": "LTC",
"free": "4763368.68006011",
"locked": "0.00000000"
}
]
}
因此,为了获得平衡值,我尝试了:
bal = client.get_account()
for i in bal:
if(i == 'balances'):
for e in i:
print(e)
但这将返回以下内容:
b
a
l
a
n
c
e
s
那么,我如何访问我的资产余额?
提前谢谢。
发布于 2021-08-30 02:04:27
直接尝试get_asset_balance()
方法
client.get_asset_balance(asset='BTC')
或者尝试从嵌套的字典bal
中提取值,如下所示:
if "balances" in bal:
for b in bal['balances']:
print(b)
https://stackoverflow.com/questions/68976942
复制相似问题