TypeError:generate_user_key()缺少1个必需的位置参数:'password'

问题描述 投票:2回答:1

我收到这样的错误

C:\Users\visitor\PycharmProjects\pastebinhacker\venv\Scripts\python.exe C:/Users/visitor/PycharmProjects/pastebinhacker/pasteb.py
Traceback (most recent call last):
  File "C:/Users/visitor/PycharmProjects/pastebinhacker/pasteb.py", line 5, in <module>
    my_key = PastebinAPI.generate_user_key(api_dev_key,username,paa,)
TypeError: generate_user_key() missing 1 required positional argument: 'password'

Process finished with exit code 1

我阅读了该模块的文档,似乎没问题

from pastebin import PastebinAPI
api_dev_key = '72e257e0475e78c2eed3db0bd68088a8'
username='san1211'
paa='sadasdiuaosd'
my_key = PastebinAPI.generate_user_key(api_dev_key,username,paa,)
print (my_key)
python pastebin
1个回答
2
投票

您需要首先实例化PastebinAPI对象。

然后你可以用你的参数调用那个对象上的generate_user_key

例:

from pastebin import PastebinAPI

api_dev_key = '72e257e0475e78c2eed3db0bd68088a8'
username='san1211'
paa='12awweqqwe'

pastbinapi_object = PastebinAPI() # Create your object to work with

my_key = pastbinapi_object.generate_user_key(api_dev_key,username,paa) # Call class method on that object.
print (my_key)

结果:

40ebfabed51dd3179a3f97f37f71c213

欢迎来到Object-oriented programming :-)

© www.soinside.com 2019 - 2024. All rights reserved.