尝试匹配包含某些文本的链接。我正在做
links = soup.find_all('a',href=lambda x: ".org" in x)
Run Code Online (Sandbox Code Playgroud)
但这会引发 TypeError: argument of type 'NoneType' is not iterable。
正确的做法显然是
links = soup.find_all('a',href=lambda x: x and ".org" in x)
Run Code Online (Sandbox Code Playgroud)
x and为什么这里需要额外的?