在scrapy中null
多个参数如何适合?如果它是可行的那么response.meta.get("something","someotherthing")
与someotherthing
的关系如何?
我搜索了很多,但找不到我之后的确切答案。
答案 0 :(得分:1)
response.meta
它只是一个普通的python dict
,而作为一个python dict,它的方法get
是无安全的 - 当第二个参数是默认值时如果第一个参数不在dict中,则放置。
例如:
而response.meta['unknown_key']
会引发KeyError异常,
response.meta.get('unknown_key')
将返回None,并且
response.meta.get('unknown_key', 'abc')
将返回abc