带有testn的web3.py isConnected()函数

2024-06-07 00:45:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用Python开发一个应用程序来处理一些问题。我已经安装了geth和web3.py,并且对isConnected()的不同行为有问题。你知道吗

Geth:Geth-alltools-darwin-amd64-1.8.15-89451f7c(最新版本)

web3.py:4.6.0(最新版本)

Python:3.7版

Mac OS X操作系统

我开始这样:

./geth --syncmode=light --cache=1024 --maxpeers=12
./geth --testnet console

示例代码:

from web3.auto import w3
if (w3.isConnected()):
    print("I am connected")
else:
    print("I am not connected")

只要我使用mainnet,isConnected()的行为就和预期的一样。如果testnet isConnected()始终为False,即使链已完全同步!你知道吗

知道我做错了什么吗?你知道吗


Tags: py版本应用程序amamd64web3testnetprint