python报错
ScrapyDeprecationWarning: scrapy.loader.processors.MapCompose is deprecated, instantiate itemloaders.processors.MapCompose instead.
解决方法:在报错的文件下加入以下打码,就可以忽略
import warnings
warnings.filterwarnings("ignore")
该方法源码
def filterwarnings(action, message="", category=Warning, module="", lineno=0,
append=False):
"""Insert an entry into the list of warnings filters (at the front).
'action' -- one of "error", "ignore", "always", "default", "module",
or "once"
'message' -- a regex that the warning message must match
'category' -- a class that the warning must be a subclass of
'module' -- a regex that the module name must match
'lineno' -- an integer line number, 0 matches all warnings
'append' -- if true, append to the list of filters
"""
import re
assert action in ("error", "ignore", "always", "default", "module",
"once"), "invalid action: %r" % (action,)
assert isinstance(message, str), "message must be a string"
assert isinstance(category, type), "category must be a class"
assert issubclass(category, Warning), "category must be a Warning subclass"
assert isinstance(module, str), "module must be a string"
assert isinstance(lineno, int) and lineno >= 0, \
"lineno must be an int >= 0"
_add_filter(action, re.compile(message, re.I), category,
re.compile(module), lineno, append=append)
action 是以下表格左侧的值:
值处理方式
“error”:将匹配警告转换为异常
“ignore”:忽略匹配的警告
“always”:始终输出匹配的警告
“default”:对于同样的警告只输出第一次出现的警告
“module”:在一个模块中只输出第一次出现的警告
“once”: 输出第一次出现的警告,而不考虑它们的位置
message: 是包含正则表达式的字符串,警告消息的开始必须匹配,不区分大小写
category: 是一个警告类型(必须是 Warning 的子类)
module :是包含模块名称的正则表达式字符串,区分大小写
lineno: 是一个整数,警告发生的行号,为 0 则匹配所有行号