# 对于POST请求,您可以通过向请求函数传递data参数来发送数据,如下所示: import urllib.request import urllib.parse url = 'https://www.baidu.com/' values = {'name': 'John', 'age': 25} data = urllib.parse.urlencode(values) data = data.encode('ascii') # data应该是bytes类型 req = urllib.request.Request(url, data) response = urllib.request.urlopen(req) print(response.read())