运行软件为pyrhon3.7.4,错误提示代码为:NameError: name 'url' is not defined
源代码展示:
import urllib.request
#创建request对象
request = urllib.request(url)
#添加数据
request.add_data('a','1')
#添加HTTP的header
request.add_header('User-Agent','Mozilla/5.0')
#发送请求获取结果
response = urllib.request.uelopen(request)
运行显示错误
错误提示展示:
Traceback (most recent call last):
File "D:\pythonfile\crawles1.py", line 3, in <module>
request = urllib.request(url)
NameError: name 'url' is not defined
最后一句
NameError: name 'url' is not defined
说没有定义url,课程中也没有定义
如果要定义,那改怎么定义这个url?