gpt4 book ai didi

python - 名称错误 : name 're' is not defined

转载 作者:太空狗 更新时间:2023-10-29 17:13:50 24 4
gpt4 key购买 nike

<分区>

我是 python 的新手。很新。我从教程中复制了以下内容

#!/usr/bin/python

from urllib import urlopen
from BeautifulSoup import BeautifulSoup

webpage = urlopen('http://feeds.huffingtonpost.com/huffingtonpost/LatestNews').read

patFinderTitle = re.compile('<title>(.*)</title>')

patFinderLink = re.compile('<link rel.*href="(.*)"/>')

findPatTitle = re.findall(patFinderTitle,webpage)

findPatLink = re.findall(patFinderLink,webpage)

listIterator = []
listIterator[:] = range(2,16)

for i in listIterator:
print findPatTitle[i]
print findPatLink[i]
print "\n"

我得到错误:

Traceback (most recent call last):
File "test.py", line 8, in <module>
patFinderTitle = re.compile('<title>(.*)</title>')
NameError: name 're' is not defined

我做错了什么?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com