簡體   English   中英

如何修復 - TabError:在縮進中使用不一致的制表符和空格

[英]How to fix - TabError: inconsistent use of tabs and spaces in indentation

我正在嘗試使用pythonBeautifulSoup庫從網絡論壇中抓取問題。

以下是我試圖回答問題的方式:

from bs4 import BeautifulSoup
import requests

url="https://forum.bouyguestelecom.fr/questions/browse?utf8=%E2%9C%93&flow_state=published&search=&order=created_at.desc"
req=requests.get(url).text

soup=BeautifulSoup(req, 'html.parser')
questions =soup.find_all("ul", class_="questions")

for question in questions:
    contents = soup.find_all("li", class_="questions-content first odd")
    for content in contents:
    ques=question.find("a", class_="content_permalink").text
    print(ques)

html 的樣子: html

第一個循環以獲取帶有課堂問題的 ul

然后是一個循環來獲取里面的 li

然后得到a的內容

我的邏輯對嗎??

我的問題:

    ques=question.find("a", class_="content_permalink").text
TabError: inconsistent use of tabs and spaces in indentation

要解決錯誤問題,請調整縮進:

for content in contents:
    ques=question.find("a", class_="content_permalink").text
    print(ques)

代替

for content in contents:
ques=question.find("a", class_="content_permalink").text
print(ques)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM