![](/img/trans.png)
[英]Python Selenium TypeError: __init__() takes 1 positional argument but 2 were given
[英]Python Inheritance - TypeError: __init__() takes 1 positional argument but 4 were given
import requests
class Poll(requests.session()):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
with Poll() as p:
# do stuff
>>TypeError: __init__() takes 1 positional argument but 4 were given
我不明白為什么會拋出錯誤。 *args 不處理任何額外的位置參數嗎?
發現問題。 requests.session 是一個函數,它返回類requests.Session 的一個實例。
固定代碼:
import requests
class Poll(requests.Session):
def __init__(self):
super().__init__()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.