当我运行以下命令时,我得到“AttributeError:'NoneType'对象没有属性'string'”。但是,当对块字符串变量执行相同的任务时;有用。
关于我做错了什么的任何想法?
from BeautifulSoup import BeautifulSoup
from urllib import urlopen
url = ("https://en.wikipedia.org/w/api.php?action=query&prop=extracts&titles=Albert%20Einstein&explaintext")
print ((BeautifulSoup(((urlopen(url)).read()))).find('extract').string).split("\n", 1)[0]