如果在以太坊地址中发现任何余额,我该如何设置停止?

how can I set to stop if found any balance in ethereum addresses?

import pyetherbalance
from ethereum import utils
import time
import secrets
start = time.time()

a = 1
while (a <= 10000):

elapsed_time = time.time() - start
# Sign up for https://infura.io/, and get the url to an ethereum node
infura_url = 'https://mainnet.infura.io/v3/d02854d5c8ae4e24affc2447b6895073'

private_key = utils.sha3(secrets.token_hex(8))
raw_address = utils.privtoaddr(private_key)
account_address = (utils.checksum_encode(raw_address))
z = utils.encode_hex(private_key)
# Create an pyetherbalance object , pass the infura_url
ethbalance = pyetherbalance.PyEtherBalance(infura_url)
# get ether balance
balance_eth = ethbalance.get_eth_balance(account_address)
balance_usdt = ethbalance.get_token_balance('USDT', account_address)
balance_omg = ethbalance.get_token_balance('OMG', account_address)
balance_bnb = ethbalance.get_token_balance('BNB', account_address)
balance_wbtc = ethbalance.get_token_balance('WBTC', account_address)
print (z+' '+account_address+' '+ str(a))
print(balance_eth)
a = a + 1
# get token balance 
print(balance_usdt,balance_omg,balance_bnb,balance_wbtc)

我希望我的程序停止或继续 运行 但只保存有余额(eth 或代币余额)的地址

if balance_eth!=0.0:
  #print("EUREKA...EUREKA...EUREKA...")
  print(z, account_address, balance_eth, balance_usdt, balance_omg, balance_bnb, balance_wbtc,
  file=open("esleme.txt", "a"))

[output][1]


[1]: https://i.stack.imgur.com/nFwuU.jpg

从您的示例结果屏幕截图中,balance_eth 是一个字典,其中 balance 作为键之一。您可以通过以下模式访问它。

balance_eth = {'balance': 0.8}

print(balance_eth)

if balance_eth['balance'] > 0:
    # do the processing of printing or saving to file