[英]How can I get my Tron(TRC20) Address from my Binance Account vie API using Python
I wanted to get my Tron(TRC20) Address from my Binance Account vie API using Python, but all i got was my (Eth) Network Address.我想从我的 Binance 帐户 vie API 使用 Python 获取我的 Tron(TRC20)地址,但我得到的只是我的(Eth)网络地址。
**This is my code below.**
rom lib2to3.pygram import Symbols
import os
import config, csv
#and then import it in your python file with
from binance.client import Client
client = Client(config.api_key, config.api_secret)
address = client.get_deposit_address(tag='', coin='USDT')\
USDTron = (address.get('TRC20'))\
Results:结果:
print(address)
Output: {'coin': 'USDT', 'address': '0x1892e6d25a9d91dea9f9caac549261e601af97f8', 'tag': '', 'url': 'https://etherscan.io/address/0x1892e6d25a9d91dea9f9caac549261e601af97f8'}
***(I got my Eth Network Address as the output)***
print(USDTron)
Output: None
**The output was (None)**
I believe you might not quite understand what the python dictionary get()
method does.我相信你可能不太明白 python 字典get()
方法的作用。
According to W3schools "The get() method returns the value of the item with the specified key."根据W3schools ,“get() 方法返回具有指定键的项目的值。”
The output from client.get_deposit_address(tag='', coin='USDT')
doesnt have a key called TRC20 which is why get('TRC20')
is returning None
.来自client.get_deposit_address(tag='', coin='USDT')
USDT') 的 output 没有名为 TRC20 的密钥,这就是get('TRC20')
返回None
的原因。 If you used get('url')
it would work and return a value since there is a key called url
in the dictionary.如果您使用get('url')
它会起作用并返回一个值,因为字典中有一个名为url
的键。
Furthermore, in order to retrieve the TRC20 deposit address instead of the default ERC20 address, you need to specify an additional optional parameter which is called network
as defined in the Binance API docs :此外,为了检索 TRC20 存款地址而不是默认的 ERC20 地址,您需要指定一个额外的可选参数,该参数称为 Binance API 文档中定义的network
:
address = client.get_deposit_address(tag='', coin='USDT', network='TRX')
USDTron = address.get('address')
The.network name is found in the dropdown on the binance deposit address webpage. .network 名称可在币安存款地址网页的下拉列表中找到。 For TRC20 it's TRX.对于 TRC20,它是 TRX。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.