刚开始学想弄个爬虫玩玩但是照着把代码敲进去会报错,又不懂英语只能来这里问问。
代码如下from urllib.request import urlopen
urt = 'http://www.baidu.com'
repr = urlopen(urt)
print(resp.read())
报错内容如下
Traceback (most recent call last):
File "D:\计算机语言\pycharm\venv\demo.py", line 9, in <module>
print(resp.read())
NameError: name 'resp' is not defined
Process finished with exit code 1
print(resp.read())
改成
print(repr.read()) NameError: name 'resp' is not defined
的意思是
NameError: 'resp' 未定义 修正一下拼写:
from urllib.request import urlopen
url = 'http://www.baidu.com'
res = urlopen(url)
print(res.read()) ckblt 发表于 2022-3-16 18:01
谢谢,我改完问题就解决了
页:
[1]