“属性”对象不可调用

rab*_*sif 0 python django ethereum web3-donotuse

所以我已经连接到合同,这似乎工作正常,我正在尝试使用这个类:来自https://web3py.readthedocs.io/en/stable/web3.personal.html 的web3.personal.Personal和我似乎不明白我错了什么......当我打印(web3.personal.Personal)给我一个类对象但我似乎无法使用与这个类相关的任何函数,说我缺少“self”参数

contract_abi = my_abi
w3 = Web3(HTTPProvider(myurl))
myContract = w3.eth.contract(address ,abi)
ref = ref = web3.personal.Personal('web3')
print(ref) #this works   
print(ref.newAccount(password='the-passphrase')) #This crashes

TypeError: newAccount() missing 1 required positional argument: 'self'
TypeError: 'property' object is not callable
Run Code Online (Sandbox Code Playgroud)

not*_*353 5

似乎web3.personal.Personal是一个类,所以为了创建一个对象你需要说ref = web3.personal.Personal()

请注意,类通常(但不总是)用大写字母书写。