首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AttributeError:'Web3‘没有属性'shh’

AttributeError:'Web3‘没有属性'shh’
EN

Ethereum用户
提问于 2018-07-14 13:20:02
回答 1查看 240关注 0票数 0

Web3.py版本: 4.2.1 Python: 3.5.2 OS: linux版本:1.8.0-不稳定

我运行geth时使用的是-shh标志和-rpcapi "admin、eth、net、web3、调试、shh“。

代码语言:javascript
复制
from web3 import Web3, HTTPProvider
web3 = Web3(HTTPProvider('http://localhost:8545'))          

print ("web3 =", web3.version.api) #4.2.1
print(web3.shh) #error occurs

当我试图运行上面的代码时,我有以下错误:

代码语言:javascript
复制
Traceback (most recent call last):
  File "dd.py", line 11, in <module>
    print(web3.shh)
AttributeError: 'Web3' object has no attribute 'shh'
EN

回答 1

Ethereum用户

回答已采纳

发布于 2018-07-14 13:31:29

您需要执行以下操作:

代码语言:javascript
复制
from web3.shh import Shh
Shh.attach(web3, "shh")
print(web3.shh)
票数 1
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/54370

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档