我正在尝试在 python 中使用 web3。
我正在尝试按照 http://web3py.readthedocs.io/en/stable/web3.eth.html#web3.eth.Eth 中的步骤操作
import web3
web3.eth.getBlock("1028201")
但是得到了
AttributeError: module 'web3.eth' has no attribute 'getBlock'
我在 python 3 和 python 2.7 中都尝试过,得到了相同的结果。
有什么建议吗?
最佳答案
您使用的语法是错误的, 属性 eth 属于 WEB3 对象,而不是类本身 试试这个,它会起作用
from web3 import Web3
# Create an object from the WEB3 lib
w3 = Web3(Web3.IPCProvider())
#then use the eth attribute on it
w3.eth.getBlock("1028201")
关于python - 如何修复 web3 模块 AttributeError?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48181275/