次のコマンドを実行すると、「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]