18 lines
394 B
Python
18 lines
394 B
Python
#-*- encoding:utf-8 -*-
|
||
|
||
'''
|
||
@Author : dingjiawen
|
||
@Date : 2023/10/17 21:40
|
||
@Usage : urllib库学习
|
||
@Desc :
|
||
'''
|
||
|
||
import urllib.request
|
||
|
||
# 基本使用,返回一个response对象
|
||
# 无data即get请求;有data即post请求,data为bytes类型
|
||
response = urllib.request.urlopen("https://www.python.org")
|
||
|
||
print(response.status)
|
||
print(response.getheaders())
|
||
print(response.getheader('Server')) |