第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Python - 缺少 1 個(gè)參數(shù),即使我提供了它

Python - 缺少 1 個(gè)參數(shù),即使我提供了它

慕斯709654 2023-08-22 18:27:12
我正在提供論據(jù),但仍然收到錯(cuò)誤。我什至嘗試將其作為字符串提供。錯(cuò)誤:C:\anaconda3\python.exe C:/Test/browser_automation/app.pyEnter the author you'd like quotes from: testtestTraceback (most recent call last):  File "C:/Test/browser_automation/app.py", line 14, in <module>    page.select_author(author)TypeError: select_author() missing 1 required positional argument: 'author_name'Process finished with exit code 1app.pyfrom selenium import webdriverfrom pages.quotes_page import QuotesPagechrome = webdriver.Chrome(executable_path="c:\\Test\\chromedriver.exe")chrome.get('http://quotes.toscrape.com/search.aspx')page = QuotesPage(chrome)author = input("Enter the author you'd like quotes from: ")print(author)page.select_author(author) ## Still reports error#page.select_author('author')  ## Tried it as a string as well and it still reports error.quote_page.py部分內(nèi)容:    @property    def select_author(self, author_name: str):        self.author_dropdown.select_by_visible_text(author_name)quote_page.py 完整文件:from typing import Listfrom selenium.webdriver.support.ui import Selectfrom locators.quotes_page_locators import QuotesPageLocatorsfrom parsers.quote import QuoteParserclass QuotesPage:    def __init__(self, browser):        self.soup = browser    @property    def quotes(self) -> List[QuoteParser]:        # locator = QuotesPageLocators.QUOTE        # quote_tags = self.browser.select(locator)        # return [QuoteParser(e) for e in quote_tags]        # return [QuoteParser(e) for e in self.soup.select(QuotesPageLocators.QUOTE)]        return [            QuoteParser(e) for e in self.browser.find_elements_by_css_selector(                QuotesPageLocators.QUOTE            )        ]
查看完整描述

1 回答

?
牧羊人nacy

TA貢獻(xiàn)1862條經(jīng)驗(yàn) 獲得超7個(gè)贊

Property ( @property) 方法不能接受任何參數(shù)

因此,將您的財(cái)產(chǎn)從

@property
def select_author(self, author_name: str):
   self.author_dropdown.select_by_visible_text(author_name)

def select_author(self, author_name: str):
    self.author_dropdown.select_by_visible_text(author_name)


查看完整回答
反對 回復(fù) 2023-08-22
  • 1 回答
  • 0 關(guān)注
  • 232 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號