我有这个脚本-
import lxml
from lxml.cssselect import CSSSelector
from lxml.etree import fromstring
from lxml.html import parse
website = parse('http://example.com').getroot()
selector = website.cssselect('.name')
for i in range(0,18):
print selector[i].text_content()
正如您所看到的,for 循环在我预先设置的多次后停止。我希望 for 循环仅在打印完所有内容后才停止。