python-3.x - Scrapy TabError:标识中制表符和空格的使用不一致
问题描述
import scrapy
class QuotesSpider(scrapy.Spider):
name = "quotes"
def start_requests(self):
urls = [
'http://quotes.toscrape.com/page/1/',
'http://quotes.toscrape.com/page/2/'
]
for url in urls:
yield scrapy.Requests(url=url, callback=self.parse)
def parse(self, response):
page = response.url.split("/")[-2]
filename = 'quotes-%s.html' % page
with open(filename, 'wb') as f:
f.write(response.body)
self.log('Saved file %s' % filename)
当我使用“scrapy crawl quotes”执行此文件时,我在第 7 行遇到错误,它标记了我的“[”并说:TabError:在标识中使用制表符和空格不一致,但我想知道为什么,因为我假设我正确地“复制了” “视频中的代码,我测试了几个身份。目前我正在使用 18.04 ubuntu lts 服务器
解决方案
推荐阅读
- openpyxl - 使用 openpyxl 模块处理包含 xlsx 文件的文件夹
- .net - 此程序可能未正确运行
- angular - 垫树角度中的 FlatTreeControl.getDescendants 错误
- java - 如何在android的多行edittext中更改光标位置?
- c++ - C++ std::thread 和 std::async 测试正在进行中,但发生错误
- python - 将变换矩阵应用于新的点集
- django - Django 使用 DEBUG = False 和 Nginx 在错误目录中查找媒体文件
- javascript - Visual Studio Code:在“props”之后键入点会导致它自动完成为“ImagePropTypes” - 为什么?
- android - 在 Android 中使用默认相机意图访问所有相机镜头
- c# - 如何在嵌套数组上使用 DateRange 查询 Elasticseach?