import lxml.html,requests
ur1='https://peps.python.org/pep-0020/#the-zen-of-python'
xpath='//*[@id="the zen of python"]/pre/text()'
res=requests.get(ur1)
ht=lxml.html.fromstring(res.text)
text=ht.xpath(xpath)
print('Hello,\n'+''.join(text))
就是这么打出来的
执行之后只能出个hello
你这个xpath取到的内容本来就是空的,当然打印不出东西