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

时间:2019-04-19 06:21:36

标签: python pastebin

我遇到这样的错误

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)

1 个答案:

答案 0 :(得分: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:-)