【发布时间】:2020-05-19 04:34:23
【问题描述】:
我在这里需要帮助。在下面的代码中,我希望 FOR 循环遍历所有列出了相关 API KEY 和 SECRET 的帐户,只要余额大于零,就将比特币从它们一个接一个地发送到收件人电子邮件地址:
#!/data/data/com.termux/files/usr/bin/python3.8
from coinbase.wallet.client import Client
import json
api_key1 = '<key>'
api_secret1 = '<secret>'
api_key2 = '<key>'
api_secret2 = '<secret>'
api_key3 = '<key>'
api_secret3 = '<secret>'
api_key4 = '<key>'
api_secret4 = '<secret>'
api_key5 = '<key>'
api_secret5 = '<secret>'
client = Client(api_key, api_secret)
accounts = client.get_accounts()['data']
for account in accounts:
sending_currency = account['currency']
if float(account['balance']['amount']) > 0:
#Send to other account
sending_account = client.get_account(account['id'])
sending_amount = account['balance']['amount']
print('sending %s %s from SENDER_EMAIL_ADDRESS' %(sending_amount, sending_currency))
sending_account.send_money(to = 'RECEPIENT_EMAIL_ADDRESS', amount = sending_amount, currency = sending_currency)
【问题讨论】:
-
您面临的问题是什么?什么不起作用?
-
它适用于单个帐户。但是我想修改脚本来循环遍历指定了 API 和 SECRET 的 5 个帐户。
标签: python-3.x for-loop coinbase-api termux