爬虫:使用Requests模块基本使用_response=requests.port(-程序员宅基地

技术标签: 爬虫  request  python  urllib  爬虫【python】  

 

目录

安装Requests

示例引入

GET请求

抓取网页

抓取二进制数据

 POST请求

常用的响应

我们了解urllib的基本用法,但是其中确实有不方便的地方,比如处理网页验证和 ookies时,需要写 Opener 和Handler来处理.。为了更加方便地实现这些操作,就有了更为强大的库request ,有了它, Cookies 、登录验证、代理设置等操作都不是事儿。

安装Requests

pin install requests

示例引入

import requests

response = requests.get("https://www.baidu.com")
print(type(response))
print(response.status_code)
print(type(response.text))
print(response.text)
print(response.cookies)

结果
<class 'requests.models.Response'>
200
<class 'str'>
<!DOCTYPE html>
<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge> </div> </div> </div> </body> </html>

<RequestsCookieJar[<Cookie BDORZ=27315 for .baidu.com/>]>

这里我们调用 get() 方法实现与 urlopen() 相同的操作,得到一个 Response 对象,然后分别输出 Response 的类型、状态码、响应体的类型、以及内容 及Cookies

通过运行结果可以发现,它的返回类型是 requests.models .Response 响应体的类型是字符串str, Cookies 的类型是Req uestsCookieJar

GET请求

HTTP中最常见的请求之一就GET是请求,下面首先来详细了解一下利用 Requests 构建 GET 请求的方法
 

import requests

data = {
    "age":22,
    "name":"python"
}

reponse = requests.get("http://192.168.1.104/get",params=data)
print(type(reponse.text))
print(reponse.json())
print(type(reponse.json()))

结果:
<class 'str'>
{'args': {'age': '22', 'name': 'python'}, 'headers': {'Accept': '*/*', 'Accept-Encoding': 'gzip, deflate', 'Connection': 'keep-alive', 'Host': '192.168.1.104', 'User-Agent': 'python-requests/2.25.1'}, 'origin': '192.168.1.101', 'url': 'http://192.168.1.104/get?age=22&name=python'}
<class 'dict'>

可以发现调用json()方法,就可以将返回结果是JSON格式的字符串转化为字典,但需要注意的是,如果返回结果不是 JSON 式,便会出现解析错误,抛出 json.decoder. JSONDecodeError 异常

抓取网页

上面的请求链接返回的是 JSON 形式的字符串, 那么如果请求普通的网页,则肯定能获得相应的内容了

import requests
import re

headers = {
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36"
}
reponse = requests.get("https://www.zhihu.com/explore",headers=headers)
pattern = re.compile('"ExploreSpecialCard-contentTitle".*?.data-za-detail-view-id="5794"*?>(.*?)</a>',re.S)
title = re.findall(pattern,reponse.text)
print(title)


结果:
['提示一:成为风险管理者', '时间旅人:上知乎的穿越者能透露一点未来的事吗?', '「保险」到底保险吗?', '【答案年终秀】本届天团向知乎网友问好', '你认为中国青年准备好走向世界舞台中央了吗?', '如何评价现在的大学生?', '哪些细思极恐的行为会让你感染HPV?', '哪些细思极恐的行为会让你感染HPV?', '接种 hpv 疫苗时,有哪些注意事项?', '长寿时代,不少人成了「困在长寿里的人」,该如何破局?', '健康问题让你对生活做出了哪些妥协?', '如何拥有一个充实而又愉快的老年生活?']

这样就可以提取其中的文本信息了

抓取二进制数据

在上面的例子中,我们抓取的是知乎的一个页面 实际上它返回的是 HTML 文档 如果想抓取图片、音频、 视频等文件,应该怎么办呢?

图片、音频、视频这些文件本质上都是由二进制码组成的,由于有特定的保存格式和对应的解析方式, 我们才可以看到这些形形色色的多媒体 所以,想要抓取它们,就要拿到它们的二进制码

import requests


headers = {
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36"
}
reponse = requests.get("https://static.zhihu.com/heifetz/favicon.ico",headers=headers)
print(reponse.text)
print(reponse.content)

结果;
           ¨     (       @                                     �e `�g Ώ�e ώ�f ��f ��f��f ��f ��f ��f ��f ��f ��f ��f ��fώ�f��f��e ��f ��fώ�g ώ�j��k ��lξ�o Ώ�q _                �` �f Ο�e ώ�f ��f ��e ώ�f ��f ��f ��f ��fώ�eώ�f��e ��fώ�f��f ��f ��f��f ��g��h ��i ��k ��l ��n ��p ��q ώ�t Ώ�p         �eΏ�eώ�f ��f ��f��f ��f ��f ��f ��f ��f ��f ��f ��g��f ��fώ�f ��f ��f ��g ��h ώ�j ��l ��lώ�n ��p ��r ��s ��u ��w Ο    �f _�f ��f ��fώ�f ��f ��f��f ��e ώ�f��fώ�e ώ�f ��eώ�e ώ�fώ�eώ�f ��f��g ��i ��j ��l ��n ��o ��p ��qώ�t ��u ��v ��x��y _�g Ώ�e ��f��f ��f ��f ��f ��f ��e ώ�e ώ�f ��f ��f��f ��f ��f ��f��g��g ��i ��k ��l ��n��oώ�p ώ�r��s ��u ώ�v ��x ��y ώ�{ Ώ�fξ�f��f ��e ώ�f���@���`���@��f ��e ώ�eώ�f��f ��e ώ�f ��e ώ�fώ�h ��i ��k ��lώ�m ώ�o ��qώ�s ��sώ�u ώ�v ��y ��z ��{ώ�}��f ��fώ�e ��f ��e ώ� `��υο������ΨΏ��y ώ�f ��f ��f��e ώ�f��Ε ��h ��j��k ��lώ�Ι ��”@��q ��s ��t ��v��w ��x ώ�z ��{ ��}ώ� ��e ώ�f��f ��f ��f ��f ��‚0��υο������μί��f ��fώ�e ώ�f ��p������s��l ��m ��n ��φο������Β���}��uώ�x ��y ��z ώ�|��}ώ�€��€ ��f ��f ώ�f ��f ��f ��f ��f ���`����������³€ώ�eώ�f ��z!��υο������~ ��¤`��������������������������������������| ώ�~��€ ��€ ώ�‚ ώ�e ώ�f ��f��f��e ��f��fώ�f ��Ε ������μί��y ��g ��ΩΏ������ΪΏ��m��¥`��������������—@��Υ―������������������~ ��€��€ώ�‚ ώ�„��f ��f ��f ��f ��f ��f ��f��fώ�x!ώ���������΅`��¬pώ�����φο��€ ώ�o ώ�¦`������άΏ��u ��vώ�x ��z ��‹ ����������€ ���ώ�‚ώ�„ ��… ��f ��f ��e ώ�f��g��f ��eώ�f ��f ��Ζ ������ΪΏ��μί������p��p ��q ��§`������έΏ��w ώ�y ��yώ�| ���!ώ���������‚ ��ƒ ��… ��† ��� ��fώ�f ��f ��f ��f ��f��e ώ�f ��g ���@ώ�����φο�� ��ΐ���p ��qώ�s ��¨`������ήΏ��y ��z ώ�|��~��� ����������ƒ ��… ��‡�����‰ ��fώ�f ��f ��f ��f��f ��f ��f ώ�hώ�j ��φο������‰1ώ�p��q ��s ��tώ�`������ήΏ��{��}��} ώ� ��‘!ώ���������…��‡���ώ�� ���ώ�f��fώ�fώ�f ��f��p��z!ώ�{ ώ�} ��~ ��δΟ�������P��qώ�s ��u ��v ��«aώ�����ήΏ��} ��~ �� ��€ώ�’ ����������‡ ��‰��‰ ώ�‹ ώ��ώ�f ��f��fώ�f ��fώ�½�������������������������������������������ξί��­`ώ�����ίΏ��~��€ώ�� ��ƒ ��” ����������‰������������ ��f ��f��fώ�f ��h ��| ��ΪΏ��μί��νί��νί��φο������χο��ξί��ξί��οί��Ξ���­`������ίΏ��€��� ��ƒ ��„ ώ�• ����������‹��� ������ ��‘ ώ�f��f ��g ��i ��i ��k ��m��n ώ�p ��q ��Ή€������Λ���w ��y��z ώ�{ ��`������ΰΏ��‚ ��ƒώ�… ��†ώ�—!ώ���������� ώ�� ��� ��‘ ��“ώ�f ��g ��i��j ��l ��m ��o ��p ��r ��s ��Ή€������Μ���y ��{��| ��~ ��―`������ΰΏ��„ ��… ��‡ ��‡ώ�� ����������� ��� ώ�‘��“ώ�” ��g ��i��jώ�lώ�m ��›P��―pώ�zώ�t��u ��Ί€������Ν���{ ��|ώ�~ ��€ ��°a������ΰΏ��… ��‡ ώ�� ���ώ�� ����������� ��’ ��“ ��” ��— ώ�i ��j ��l ��m ��o ��”@������ξί��‡ ��w��Ό€������Ξ���| ��~ ��€ ��� ��±`������ΰΏ�����‰ ��� �����› ����������’��“��• ��—ώ�� ��j ώ�m��n��p��q ��r ��άΏ������Γ���xώ�Ό€������Ο���~ ��€��� ��ƒώ�²`������αΏ��‰��� ��� ��� ��� ����������”��• ��—ώ�� ��� ��lώ�nώ�p ��q ��s ��t ώ�`������χο��ήΏ��οί������χο��ίΏ��ίΏ��ίΏ��³`��³a������χο��αΏ��γΏ��γΏ��γΏ��γΏ����������• ��— ώ�� ��� ��› ��n ��p ��q ��s ώ�u ��v ��� ��������������������������������������΄`��΄`��������������������������������������� ώ���� ��� �����q ��qώ�s ��u ��v ��x ��yώ�Φ―������Η��� @ώ�΅@��΅@��£@ώ�¤@��¥@��‰��‘��@���@��«@��¬@��­@��@��―@��°@��²@�� ��› ώ����� ώ�� ��r ��t��u ��v ��xώ�y ώ�{��­`������ηΟ��� ��‚ ��…��†��‡ ώ�‰ ��� ώ�� ��� ��� ��� ��’ώ�“ ��–ώ�– ��� ��� ώ�› ������ ώ�� ��΅ ��t ��u��w ��x ��z��{ ��} �� ��·p��χο��“ ώ�„ ��… ��‡ ��� ώ�‹ ������ ��� ��‘��’��” ��• ��—ώ��ώ�� ��›������ ��  ώ�΅ ��£ ο�wΏ�w ��y ��zώ�{ ��} �� ��€ ��‚��„ ��… ��† ώ�‡ώ�‰ ��‹ώ�� ���ώ�� ��‘ώ�“ ��•ώ�• ��— ��� ��� ������ �����  ��Ά��£��¤ Ώ�x `�y��z ��|��~��€ ��€ ��‚��ƒ ��… ώ�†��� ��� ��‹��� ��� ��� ��‘ ��“ ��• ��–ώ�— �� ��› ώ��ώ����� ��  ��Ά��£ ��¥ ��¦ _    �zΟ�| ��~ώ�€��� ��‚��ƒώ�†��† ώ��ώ��ώ�‹ώ�� ��� ώ�� ώ�‘ ��“ ώ�• ��— ώ�— �� ��� ��� ���ώ�� ��΅ ��Ά��¤ώ�¥ ��§ Ώ        �€ �} Ώ�€ώ�� ��ƒ ��„ώ�… ��‡��‰��� ��‹ ���ώ�� ��� ��’ώ�” ώ�” ��– ��� �� ��› ��� ��� �����΅��Ά��£ ��¥ ��§ Ο��                 �� _�ƒ Ώ�„ ο�… ώ�‡ ��‰ώ�� ��� ��� ���ώ�� ��’��”��• ��— ��� ���ώ�› ���ώ�� ��� ��΅ ��£��¤ ��¥ Ώ�¦ _            ΰ  €  €                                                                                                          €  €  ΰ  
b'\x00\x00\x01\x00\x01\x00  \x00\x00\x01\x00 \x00\xa8\x10\x00\x00\x16\x00\x00\x00(\x00\x00\x00 \x00\x00\x00@\x00\x00\x00\x01\x00 \x00\x00\x00\x00\x00\x00\x10\x00\x00\x13\x0b\x00\x00\x13\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xffe\x00`\xffg\x00\xbf\xffe\x00\xfe\xfff\x00\xff\xfff\x00\xff\xfff\x01\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x01\xfe\xfff\x01\xff\xfff\x01\xff\xffe\x00\xff\xfff\x00\xff\xfff\x01\xfe\xffg\x00\xfe\xffj\x01\xff\xffk\x00\xff\xffl\x01\xee\xffo\x00\xbf\xffq\x00_\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff`\x00\x10\xfff\x00\xcf\xffe\x00\xfe\xfff\x00\xff\xfff\x00\xff\xffe\x00\xfe\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x01\xfe\xffe\x01\xfe\xfff\x01\xff\xffe\x00\xff\xfff\x01\xfe\xfff\x01\xff\xfff\x00\xff\xfff\x00\xff\xfff\x01\xff\xfff\x00\xff\xffg\x01\xff\xffh\x00\xff\xffi\x00\xff\xffk\x00\xff\xffl\x00\xff\xffn\x00\xff\xffp\x00\xff\xffq\x00\xfe\xfft\x00\xbf\xffp\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\xffe\x01\xbf\xffe\x01\xfe\xfff\x00\xff\xfff\x00\xff\xfff\x01\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xffg\x01\xff\xfff\x00\xff\xfff\x01\xfe\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xffg\x00\xff\xffh\x00\xfe\xffj\x00\xff\xffl\x00\xff\xffl\x01\xfe\xffn\x00\xff\xffp\x00\xff\xffr\x00\xff\xffs\x00\xff\xffu\x00\xff\xffw\x00\xcf\x00\x00\x00\x00\xfff\x00_\xfff\x00\xff\xfff\x00\xff\xfff\x01\xfe\xfff\x00\xff\xfff\x00\xff\xfff\x01\xff\xfff\x00\xff\xffe\x00\xfe\xfff\x01\xff\xfff\x01\xfe\xffe\x00\xfe\xfff\x00\xff\xffe\x01\xfe\xffe\x00\xfe\xfff\x01\xfe\xffe\x01\xfe\xfff\x00\xff\xfff\x01\xff\xffg\x00\xff\xffi\x00\xff\xffj\x00\xff\xffl\x00\xff\xffn\x00\xff\xffo\x00\xff\xffp\x00\xff\xffq\x01\xfe\xfft\x00\xff\xffu\x00\xff\xffv\x00\xff\xffx\x01\xff\xffy\x00_\xffg\x00\xbf\xffe\x00\xff\xfff\x01\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xffe\x00\xfe\xffe\x00\xfe\xfff\x00\xff\xfff\x00\xff\xfff\x01\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x01\xff\xffg\x01\xff\xffg\x00\xff\xffi\x00\xff\xffk\x00\xff\xffl\x00\xff\xffn\x01\xff\xffo\x01\xfe\xffp\x00\xfe\xffr\x01\xff\xffs\x00\xff\xffu\x00\xfe\xffv\x00\xff\xffx\x00\xff\xffy\x00\xfe\xff{\x00\xbf\xfff\x01\xee\xfff\x01\xff\xfff\x00\xff\xffe\x00\xfe\xfff\x01\xff\xff\x8d@\xff\xff\x9f`\xff\xff\x8c@\xff\xfff\x00\xff\xffe\x00\xfe\xffe\x01\xfe\xfff\x01\xff\xfff\x00\xff\xffe\x00\xfe\xfff\x00\xff\xffe\x00\xfe\xfff\x01\xfe\xffh\x00\xff\xffi\x00\xff\xffk\x00\xff\xffl\x01\xfe\xffm\x00\xfe\xffo\x00\xff\xffq\x01\xfe\xffs\x00\xff\xffs\x01\xfe\xffu\x00\xfe\xffv\x00\xff\xffy\x00\xff\xffz\x00\xff\xff{\x01\xfe\xff}\x01\xff\xfff\x00\xff\xfff\x01\xfe\xffe\x00\xff\xfff\x00\xff\xffe\x00\xfe\xff\xa0`\xff\xff\xf5\xef\xff\xff\xff\xff\xff\xff\xd8\xbf\xff\xffy \xfe\xfff\x00\xff\xfff\x00\xff\xfff\x01\xff\xffe\x00\xfe\xfff\x01\xff\xff\xc5\xa0\xff\xffh\x00\xff\xffj\x01\xff\xffk\x00\xff\xffl\x01\xfe\xff\xc9\xa0\xff\xff\x94@\xff\xffq\x00\xff\xffs\x00\xff\xfft\x00\xff\xffv\x01\xff\xffw\x00\xff\xffx\x00\xfe\xffz\x00\xff\xff{\x00\xff\xff}\x01\xfe\xff\x7f\x00\xff\xffe\x00\xfe\xfff\x01\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xff\x820\xff\xff\xf5\xef\xff\xff\xff\xff\xff\xff\xec\xdf\xff\xfff\x00\xff\xfff\x01\xfe\xffe\x00\xfe\xfff\x00\xff\xff\xa9p\xff\xff\xff\xff\xff\xffs\x10\xff\xffl\x00\xff\xffm\x00\xff\xffn\x00\xff\xff\xf6\xef\xff\xff\xff\xff\xff\xff\xc2\x90\xff\xff}\x11\xff\xffu\x01\xfe\xffx\x00\xff\xffy\x00\xff\xffz\x00\xfe\xff|\x01\xff\xff}\x01\xfe\xff\x80\x01\xff\xff\x80\x00\xff\xfff\x00\xff\xfff\x00\xfe\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xff\x9f`\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xb3\x80\xfe\xffe\x01\xfe\xfff\x00\xff\xffz!\xff\xff\xf5\xef\xff\xff\xff\xff\xff\xff~ \xff\xff\xa4`\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff|\x00\xfe\xff~\x01\xff\xff\x80\x00\xff\xff\x80\x00\xfe\xff\x82\x00\xfe\xffe\x00\xfe\xfff\x00\xff\xfff\x01\xff\xfff\x01\xff\xffe\x00\xff\xfff\x01\xff\xfff\x01\xfe\xfff\x00\xff\xff\xc5\xa0\xff\xff\xff\xff\xff\xff\xec\xdf\xff\xffy \xff\xffg\x00\xff\xff\xd9\xbf\xff\xff\xff\xff\xff\xff\xda\xbf\xff\xffm\x01\xff\xff\xa5`\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x97@\xff\xff\xd5\xaf\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff~\x00\xff\xff\x80\x01\xff\xff\x80\x01\xfe\xff\x82\x00\xfe\xff\x84\x01\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x01\xff\xfff\x01\xfe\xffx!\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xa1`\xff\xff\xacp\xfe\xff\xff\xff\xff\xff\xf6\xef\xff\xff\x80 \xfe\xffo\x00\xfe\xff\xa6`\xff\xff\xff\xff\xff\xff\xdc\xbf\xff\xffu\x00\xff\xffv\x01\xfe\xffx\x00\xff\xffz\x00\xff\xff\x8b \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x80\x00\xff\xff\x81\x01\xfe\xff\x82\x01\xfe\xff\x84\x00\xff\xff\x85\x00\xff\xfff\x00\xff\xfff\x00\xff\xffe\x00\xfe\xfff\x01\xff\xffg\x01\xff\xfff\x00\xff\xffe\x01\xfe\xfff\x00\xff\xfff\x00\xff\xff\xc6\xa0\xff\xff\xff\xff\xff\xff\xda\xbf\xff\xff\xec\xdf\xff\xff\xff\xff\xff\xff\xaep\xff\xffp\x00\xff\xffq\x00\xff\xff\xa7`\xff\xff\xff\xff\xff\xff\xdd\xbf\xff\xffw\x00\xfe\xffy\x00\xff\xffy\x01\xfe\xff|\x00\xff\xff\x8d!\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\x82\x00\xff\xff\x83\x00\xff\xff\x85\x00\xff\xff\x86\x00\xff\xff\x88\x00\xff\xfff\x01\xfe\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x01\xff\xffe\x00\xfe\xfff\x00\xff\xffg\x00\xff\xff\x8e@\xfe\xff\xff\xff\xff\xff\xf6\xef\xff\xff\x7f \xff\xff\xc0\x90\xff\xffp\x00\xff\xffq\x01\xfe\xffs\x00\xff\xff\xa8`\xff\xff\xff\xff\xff\xff\xde\xbf\xff\xffy\x00\xff\xffz\x00\xfe\xff|\x01\xff\xff~\x01\xff\xff\x8f \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x83\x00\xff\xff\x85\x00\xff\xff\x87\x01\xff\xff\x88\x01\xff\xff\x89\x00\xff\xfff\x01\xfe\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x01\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xfe\xffh\x01\xfe\xffj\x00\xff\xff\xf6\xef\xff\xff\xff\xff\xff\xff\x891\xfe\xffp\x01\xff\xffq\x00\xff\xffs\x00\xff\xfft\x01\xfe\xff\xa9`\xff\xff\xff\xff\xff\xff\xde\xbf\xff\xff{\x01\xff\xff}\x01\xff\xff}\x00\xfe\xff\x7f\x00\xff\xff\x91!\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\x85\x01\xff\xff\x87\x01\xff\xff\x88\x01\xfe\xff\x8a\x00\xff\xff\x8a\x01\xfe\xfff\x01\xff\xfff\x01\xfe\xfff\x01\xfe\xfff\x00\xff\xfff\x01\xff\xffp\x10\xff\xffz!\xfe\xff{ \xfe\xff} \xff\xff~ \xff\xff\xe4\xcf\xff\xff\xff\xff\xff\xff\x9dP\xff\xffq\x01\xfe\xffs\x00\xff\xffu\x00\xff\xffv\x00\xff\xff\xaba\xfe\xff\xff\xff\xff\xff\xde\xbf\xff\xff}\x00\xff\xff~\x00\xff\xff\x7f\x00\xff\xff\x80\x01\xfe\xff\x92 \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x87\x00\xff\xff\x89\x01\xff\xff\x89\x00\xfe\xff\x8b\x00\xfe\xff\x8d\x01\xfe\xfff\x00\xff\xfff\x01\xff\xfff\x01\xfe\xfff\x00\xff\xfff\x01\xfe\xff\xbd\x90\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xee\xdf\xff\xff\xad`\xfe\xff\xff\xff\xff\xff\xdf\xbf\xff\xff~\x01\xff\xff\x80\x01\xfe\xff\x81\x00\xff\xff\x83\x00\xff\xff\x94 \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x89\x01\xff\xff\x8a\x01\xff\xff\x8c\x01\xff\xff\x8e\x01\xff\xff\x8f\x00\xff\xfff\x00\xff\xfff\x01\xff\xfff\x01\xfe\xfff\x00\xff\xffh\x00\xff\xff| \xff\xff\xda\xbf\xff\xff\xec\xdf\xff\xff\xed\xdf\xff\xff\xed\xdf\xff\xff\xf6\xef\xff\xff\xff\xff\xff\xff\xf7\xef\xff\xff\xee\xdf\xff\xff\xee\xdf\xff\xff\xef\xdf\xff\xff\xce\x9f\xff\xff\xad`\xff\xff\xff\xff\xff\xff\xdf\xbf\xff\xff\x80\x01\xff\xff\x81\x00\xff\xff\x83\x00\xff\xff\x84\x00\xfe\xff\x95 \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x8b\x01\xff\xff\x8c\x00\xff\xff\x8e\x01\xff\xff\x8f\x00\xff\xff\x91\x00\xfe\xfff\x01\xff\xfff\x00\xff\xffg\x00\xff\xffi\x00\xff\xffi\x00\xff\xffk\x00\xff\xffm\x01\xff\xffn\x00\xfe\xffp\x00\xff\xffq\x00\xff\xff\xb9\x80\xff\xff\xff\xff\xff\xff\xcb\x9f\xff\xffw\x00\xff\xffy\x01\xff\xffz\x00\xfe\xff{\x00\xff\xff\xae`\xff\xff\xff\xff\xff\xff\xe0\xbf\xff\xff\x82\x00\xff\xff\x83\x01\xfe\xff\x85\x00\xff\xff\x86\x01\xfe\xff\x97!\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\x8c\x00\xfe\xff\x8e\x00\xff\xff\x8f\x00\xff\xff\x91\x00\xff\xff\x93\x01\xfe\xfff\x00\xff\xffg\x00\xff\xffi\x01\xff\xffj\x00\xff\xffl\x00\xff\xffm\x00\xff\xffo\x00\xff\xffp\x00\xff\xffr\x00\xff\xffs\x00\xff\xff\xb9\x80\xff\xff\xff\xff\xff\xff\xcc\x9f\xff\xffy\x00\xff\xff{\x01\xff\xff|\x00\xff\xff~\x00\xff\xff\xaf`\xff\xff\xff\xff\xff\xff\xe0\xbf\xff\xff\x84\x00\xff\xff\x85\x00\xff\xff\x87\x00\xff\xff\x87\x01\xfe\xff\x98 \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x8f\x00\xff\xff\x90\x00\xfe\xff\x91\x01\xff\xff\x93\x01\xfe\xff\x94\x00\xff\xffg\x00\xff\xffi\x01\xff\xffj\x01\xfe\xffl\x01\xfe\xffm\x00\xff\xff\x9bP\xff\xff\xafp\xfe\xffz\x11\xfe\xfft\x01\xff\xffu\x00\xff\xff\xba\x80\xff\xff\xff\xff\xff\xff\xcd\x9f\xff\xff{\x00\xff\xff|\x01\xfe\xff~\x00\xff\xff\x80\x00\xff\xff\xb0a\xff\xff\xff\xff\xff\xff\xe0\xbf\xff\xff\x85\x00\xff\xff\x87\x00\xfe\xff\x88\x00\xff\xff\x8a\x01\xfe\xff\x9a \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x90\x00\xff\xff\x92\x00\xff\xff\x93\x00\xff\xff\x94\x00\xff\xff\x97\x00\xfe\xffi\x00\xff\xffj\x00\xff\xffl\x00\xff\xffm\x00\xff\xffo\x00\xff\xff\x94@\xff\xff\xff\xff\xff\xff\xee\xdf\xff\xff\x87 \xff\xffw\x01\xff\xff\xbc\x80\xff\xff\xff\xff\xff\xff\xce\x9f\xff\xff|\x00\xff\xff~\x00\xff\xff\x80\x00\xff\xff\x81\x00\xff\xff\xb1`\xff\xff\xff\xff\xff\xff\xe0\xbf\xff\xff\x88\x01\xff\xff\x89\x00\xff\xff\x8a\x00\xff\xff\x8c\x01\xff\xff\x9b \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x92\x01\xff\xff\x93\x01\xff\xff\x95\x00\xff\xff\x97\x01\xfe\xff\x98\x00\xff\xffj\x00\xfe\xffm\x01\xff\xffn\x01\xff\xffp\x01\xff\xffq\x00\xff\xffr\x00\xff\xff\xdc\xbf\xff\xff\xff\xff\xff\xff\xc3\x90\xff\xffx\x01\xfe\xff\xbc\x80\xff\xff\xff\xff\xff\xff\xcf\x9f\xff\xff~\x00\xff\xff\x80\x01\xff\xff\x81\x00\xff\xff\x83\x01\xfe\xff\xb2`\xff\xff\xff\xff\xff\xff\xe1\xbf\xff\xff\x89\x01\xff\xff\x8a\x00\xff\xff\x8c\x00\xff\xff\x8e\x00\xff\xff\x9d \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x94\x01\xff\xff\x95\x00\xff\xff\x97\x01\xfe\xff\x98\x00\xff\xff\x9a\x00\xff\xffl\x01\xfe\xffn\x01\xfe\xffp\x00\xff\xffq\x00\xff\xffs\x00\xff\xfft\x00\xfe\xff\xa9`\xff\xff\xff\xff\xff\xff\xf7\xef\xff\xff\xde\xbf\xff\xff\xef\xdf\xff\xff\xff\xff\xff\xff\xf7\xef\xff\xff\xdf\xbf\xff\xff\xdf\xbf\xff\xff\xdf\xbf\xff\xff\xb3`\xff\xff\xb3a\xff\xff\xff\xff\xff\xff\xf7\xef\xff\xff\xe1\xbf\xff\xff\xe3\xbf\xff\xff\xe3\xbf\xff\xff\xe3\xbf\xff\xff\xe3\xbf\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x95\x00\xff\xff\x97\x00\xfe\xff\x98\x00\xff\xff\x9a\x00\xff\xff\x9b\x00\xff\xffn\x00\xff\xffp\x00\xff\xffq\x00\xff\xffs\x00\xfe\xffu\x00\xff\xffv\x00\xff\xff\x88 \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xb4`\xff\xff\xb4`\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x98\x00\xfe\xff\x99\x01\xff\xff\x9a\x00\xff\xff\x9c\x00\xff\xff\x9e\x01\xff\xffq\x00\xff\xffq\x01\xfe\xffs\x00\xff\xffu\x00\xff\xffv\x00\xff\xffx\x00\xff\xffy\x01\xfe\xff\xd6\xaf\xff\xff\xff\xff\xff\xff\xc7\x90\xff\xff\xa0@\xfe\xff\xa1@\xff\xff\xa1@\xff\xff\xa3@\xfe\xff\xa4@\xff\xff\xa5@\xff\xff\x89\x01\xff\xff\x91\x11\xff\xff\xa9@\xff\xff\xaa@\xff\xff\xab@\xff\xff\xac@\xff\xff\xad@\xff\xff\xae@\xff\xff\xaf@\xff\xff\xb0@\xff\xff\xb2@\xff\xff\x99\x00\xff\xff\x9b\x00\xfe\xff\x9c\x01\xff\xff\x9e\x00\xfe\xff\x9f\x00\xff\xffr\x00\xff\xfft\x01\xff\xffu\x00\xff\xffv\x00\xff\xffx\x01\xfe\xffy\x00\xfe\xff{\x01\xff\xff\xad`\xff\xff\xff\xff\xff\xff\xe7\xcf\xff\xff\x81\x00\xff\xff\x82\x00\xff\xff\x85\x01\xff\xff\x86\x01\xff\xff\x87\x00\xfe\xff\x89\x00\xff\xff\x8a\x00\xfe\xff\x8c\x00\xff\xff\x8d\x00\xff\xff\x8f\x00\xff\xff\x90\x00\xff\xff\x92\x01\xfe\xff\x93\x00\xff\xff\x96\x01\xfe\xff\x96\x00\xff\xff\x98\x00\xff\xff\x9a\x00\xfe\xff\x9b\x00\xff\xff\x9d\x01\xff\xff\x9e\x00\xfe\xff\x9f\x00\xff\xff\xa1\x00\xff\xfft\x00\xff\xffu\x01\xff\xffw\x00\xff\xffx\x00\xff\xffz\x01\xff\xff{\x00\xff\xff}\x00\xff\xff\x7f\x00\xff\xff\xb7p\xff\xff\xf7\xef\xff\xff\x93 \xfe\xff\x84\x00\xff\xff\x85\x00\xff\xff\x87\x00\xff\xff\x88\x00\xfe\xff\x8b\x00\xff\xff\x8c\x01\xff\xff\x8d\x00\xff\xff\x8f\x00\xff\xff\x91\x01\xff\xff\x92\x01\xff\xff\x94\x00\xff\xff\x95\x00\xff\xff\x97\x01\xfe\xff\x98\x01\xfe\xff\x9a\x00\xff\xff\x9b\x01\xff\xff\x9d\x01\xff\xff\x9e\x00\xff\xff\xa0\x00\xfe\xff\xa1\x00\xff\xff\xa3\x00\xef\xffw\x01\xbf\xffw\x00\xff\xffy\x00\xff\xffz\x01\xfe\xff{\x00\xff\xff}\x00\xff\xff\x7f\x00\xff\xff\x80\x00\xff\xff\x82\x01\xff\xff\x84\x00\xff\xff\x85\x00\xff\xff\x86\x00\xfe\xff\x87\x01\xfe\xff\x89\x00\xff\xff\x8b\x01\xfe\xff\x8c\x00\xff\xff\x8e\x01\xfe\xff\x8f\x00\xff\xff\x91\x01\xfe\xff\x93\x00\xff\xff\x95\x01\xfe\xff\x95\x00\xff\xff\x97\x00\xff\xff\x98\x00\xff\xff\x9a\x00\xff\xff\x9c\x01\xff\xff\x9d\x00\xff\xff\x9f\x01\xff\xff\xa0\x00\xff\xff\xa2\x01\xff\xff\xa3\x01\xff\xff\xa4\x00\xbf\xffx\x00`\xffy\x01\xff\xffz\x00\xff\xff|\x01\xff\xff~\x01\xff\xff\x80\x00\xff\xff\x80\x00\xff\xff\x82\x01\xff\xff\x83\x00\xff\xff\x85\x00\xfe\xff\x86\x01\xff\xff\x88\x00\xff\xff\x8a\x00\xff\xff\x8b\x01\xff\xff\x8d\x00\xff\xff\x8e\x00\xff\xff\x90\x00\xff\xff\x91\x00\xff\xff\x93\x00\xff\xff\x95\x00\xff\xff\x96\x01\xfe\xff\x97\x00\xff\xff\x99\x00\xff\xff\x9b\x00\xfe\xff\x9c\x01\xfe\xff\x9d\x01\xff\xff\x9f\x00\xff\xff\xa0\x00\xff\xff\xa2\x01\xff\xff\xa3\x00\xff\xff\xa5\x00\xff\xff\xa6\x00_\x00\x00\x00\x00\xffz\x01\xcf\xff|\x00\xff\xff~\x01\xfe\xff\x80\x01\xff\xff\x81\x00\xff\xff\x82\x01\xff\xff\x83\x01\xfe\xff\x86\x01\xff\xff\x86\x00\xfe\xff\x88\x01\xfe\xff\x8a\x01\xfe\xff\x8b\x01\xfe\xff\x8d\x00\xff\xff\x8e\x00\xfe\xff\x90\x00\xfe\xff\x91\x00\xff\xff\x93\x00\xfe\xff\x95\x00\xff\xff\x97\x00\xfe\xff\x97\x00\xff\xff\x99\x00\xff\xff\x9a\x00\xff\xff\x9c\x00\xff\xff\x9e\x01\xfe\xff\x9f\x00\xff\xff\xa1\x00\xff\xff\xa2\x01\xff\xff\xa4\x01\xfe\xff\xa5\x00\xff\xff\xa7\x00\xbf\x00\x00\x00\x00\x00\x00\x00\x00\xff\x80\x00\x10\xff}\x00\xbf\xff\x80\x01\xfe\xff\x81\x00\xff\xff\x83\x00\xff\xff\x84\x01\xfe\xff\x85\x00\xff\xff\x87\x01\xff\xff\x89\x01\xff\xff\x8a\x00\xff\xff\x8b\x00\xff\xff\x8d\x01\xfe\xff\x8e\x00\xff\xff\x90\x00\xff\xff\x92\x01\xfe\xff\x94\x00\xfe\xff\x94\x00\xff\xff\x96\x00\xff\xff\x98\x00\xff\xff\x99\x00\xff\xff\x9b\x00\xff\xff\x9c\x00\xff\xff\x9d\x00\xff\xff\x9f\x01\xff\xff\xa1\x01\xff\xff\xa2\x01\xff\xff\xa3\x00\xff\xff\xa5\x00\xff\xff\xa7\x00\xcf\xff\x9f\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x81\x00_\xff\x83\x00\xbf\xff\x84\x00\xef\xff\x85\x00\xfe\xff\x87\x00\xff\xff\x89\x01\xfe\xff\x8a\x00\xff\xff\x8c\x00\xff\xff\x8d\x00\xff\xff\x90\x01\xfe\xff\x90\x00\xff\xff\x92\x01\xff\xff\x94\x01\xff\xff\x95\x00\xff\xff\x97\x00\xff\xff\x98\x00\xff\xff\x9a\x01\xfe\xff\x9b\x00\xff\xff\x9d\x01\xfe\xff\x9e\x00\xff\xff\x9f\x00\xff\xff\xa1\x00\xff\xff\xa3\x01\xff\xff\xa4\x00\xff\xff\xa5\x00\xbf\xff\xa6\x00_\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x00\x00\x07\x80\x00\x00\x01\x80\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x01\x80\x00\x00\x01\xe0\x00\x00\x07'

这里打印了两行是Response对象的两个属性,一个是text【str类型】,另外一个是content【字节】

import requests


headers = {
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36"
}
reponse = requests.get("https://static.zhihu.com/heifetz/favicon.ico",headers=headers)
with open("favicon.ico","wb") as f:
    f.write(reponse.content)

结果
 

 POST请求

前面我们了解了最基本的 GET 请求另外一种比较常见的请求方式是 POST 使用 requests实现 POST 请求同样非常简单,示例如下:

import requests

date = {
    "name":"germey",
    "age":22
}

response = requests.post(url="http://192.168.1.104/post",data=date)
print(response.text)

结果:
{
  "args": {}, 
  "data": "", 
  "files": {}, 
  "form": {
    "age": "22", 
    "name": "germey"
  }, 
  "headers": {
    "Accept": "*/*", 
    "Accept-Encoding": "gzip, deflate", 
    "Connection": "keep-alive", 
    "Content-Length": "18", 
    "Content-Type": "application/x-www-form-urlencoded", 
    "Host": "192.168.1.104", 
    "User-Agent": "python-requests/2.25.1"
  }, 
  "json": null, 
  "origin": "192.168.1.101", 
  "url": "http://192.168.1.104/post"
}

常用的响应

import requests

response = requests.post(url="http://192.168.1.104/post",data=date)
print(type(response.status_code),response.status_code)
print(type(response.headers),response.headers)
print(type(response.cookies),response.cookies)
print(type(response.url),response.url)
print(type(response.history),response.history)


结果:
<class 'int'> 200
<class 'requests.structures.CaseInsensitiveDict'> {'Server': 'gunicorn/19.9.0', 'Date': 'Tue, 30 Nov 2021 14:26:55 GMT', 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'Content-Length': '468', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Credentials': 'true'}
<class 'requests.cookies.RequestsCookieJar'> <RequestsCookieJar[]>
<class 'str'> http://192.168.1.104/post
<class 'list'> []

这里分别打印输出 status_code 属性得到状态码,输出 headers 属性得到响应头,输出 cookies 属性得到 Cookies ,输出 url 属性得到URL ,输出 history 属性得到请求历史

状态码常用来判断请求是否成功,而 requests 还提供了一个 置的状态码查询对象 requests.codes, 示例如下:

import requests

response = requests.post(url="http://192.168.1.104/post",data=date)
exit() if not response.status_code == requests.codes.ok else print("Request Successfully")

结果:
Request Successfully

常用的返回码和响应的查询条件

 

 

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/Smart_look/article/details/121643058

智能推荐

kill端口对应进程_kill 1024端口进程-程序员宅基地

文章浏览阅读1.4k次。@author StormMa @date 2017-02-13 生命不息,奋斗不止!> kill80端口的进程lsof -i :8080|grep -v "PID"|awk '{print "kill -9",$2}'|sh_kill 1024端口进程

从0单排:学风侏儒——零样本学习3篇论文-程序员宅基地

文章浏览阅读394次。Zero shot learning主要是zero-shot learning相关论文的阅读,主要关注于视频方面。零样本问题现在处理视频的很少,主要是因为零样本自身就有不少的急需解决的问题:domain shiftHubness problemsemantic gap详情可以看这篇文章 零次学习(Zero-Shot Learning)入门1. 15. Objects2a..._零样本学习论文

vue3 + jsx + antd antd组件的table组件使用必备知识点_antd table组件center关键词-程序员宅基地

文章浏览阅读1.4k次。//vue3+jsx+antd// antd组件中 table组件的使用细节const model = defineComponent({name: ‘model’,setup() {let pageObj = reactive({pageCur: 1, // 当前的页数pageSize: 10, // 一页显示的条数total: 0 //总共的条数})// 表格的第一行 一般做为标题内容let tableTitle = [{title: ‘标题1’, // 标题1dataI_antd table组件center关键词

STM32F4寄存器串口DMA汇总-程序员宅基地

文章浏览阅读1.6k次。1.初始化//RCC RCC->APB1ENR|=1<<20; //使能串口5时钟 RCC->APB1ENR|=1<<19; //使能串口4时钟 RCC->APB1ENR|=1<<18; //使能串口3时钟 RCC->APB1ENR|=1<<17; //使能串口2时钟 R..._dma1_stream2

第035讲: 图形界面用户入门:EasyGui | 学习记录(小甲鱼零基础入门学习Python)_easygui图形界面编程入门-程序员宅基地

文章浏览阅读927次。(标答出处: 鱼C论坛)《零基础入门学习Python》测试题:_easygui图形界面编程入门

用IntelliJ IDEA 社区版配置web开发环境-程序员宅基地

文章浏览阅读2.4k次。IntelliJ IDEA社区版缺少的是Web方面的开发模块旗舰版: 社区版: 要用 IDEA 社区版进行web开发的话,需要自己手动配置由于IDEA社区版(Commun..._idea社区版指定不了环境

随便推点

python成绩录入系统gui_Python GUI项目实战(一)登录窗体的设计与实现-程序员宅基地

文章浏览阅读1.1k次。前言前面我们学习了Python GUI 图型化界面Tkinter的基础知识,为了检测我们的学习成果,学以致用。我们从今天开始做一个综合Tkinter案例--基于Tkinter的学生信息管理系统,一方面熟悉Tkinter项目的开发,另一方面可以把我们前面的学习专辑《小雨学Python》的知识综合在一起。基础功能介绍说明:由于我们尚未学习数据库的内容,所以我们这个应用程序开发的过程中,暂时通过文件的读..._self.geometry

android studio集成 百度云推送项目实战 注意事项-程序员宅基地

文章浏览阅读627次,点赞7次,收藏30次。说一千道一万,不如自己去行动。要想在移动互联网的下半场是自己占有一席之地,那就得从现在开始,从今天开始,马上严格要求自己,既重视业务实现能力,也重视基础和原理。基础夯实好了,高楼才能够平地而起,稳如泰山。最后为了帮助大家深刻理解Android相关知识点的原理以及面试相关知识,这里放上相关的我搜集整理的24套腾讯、字节跳动、阿里、百度2020-2021面试真题解析,我把技术点整理成了视频和PDF(实际上比预期多花了不少精力),包知识脉络 + 诸多细节。还有。

gbk与gb2312的区别_c#中gbk和gb2312有什么区别-程序员宅基地

文章浏览阅读763次。gbk与gb2312的区别举报描述不清违规检举侵权投诉|分享|2011-08-30 12:07 maozi_zhang | 浏览 61443 次可选中1个或多个下面的关键词,搜索相关资料。也可直接点“搜索资料”搜索整个问题。gbk 搜索资料 我有更好的答案举报描述不清违规检举侵权投诉|2011-08-30 12:30 网友采纳_c#中gbk和gb2312有什么区别

npm ERR! { Error: EPERM: operation not permitted, mkdir ‘C:\Program Files\nodejs\node_cache\_locks‘_npm err! error: eperm: operation not permitted, mk-程序员宅基地

文章浏览阅读323次。1. 场景:win10下安装node之后,node -v,npm -v都正常,node安装成功,但是运行npm i或者全局安装某插件时,报错: npm ERR! { Error: EPERM: operation not permitted, mkdir 'C:\Program F..._npm err! error: eperm: operation not permitted, mkdir 'c:\program files\node

HW-HJ12字符串反转_hj12 字符串-程序员宅基地

文章浏览阅读386次。题目描述接受一个只包含小写字母的字符串,然后输出该字符串反转后的字符串。(字符串长度不超过1000)输入描述:输入一行,为一个只包含小写字母的字符串。输出描述:输出该字符串反转后的字符串。示例1输入abcd输出dcba题解需要注意的是,Java中String类不可以直接取值,因此需要转换为char数组进行取值。Pythonjava..._hj12 字符串

AfxMessageBox与MessageBox函数_仿afxmessagebox-程序员宅基地

文章浏览阅读725次。创建消息提示对话框:前者调用的是MFC的底层函数库,后者调用的是最为基本的Win32 API。MessageBox()的函数原型如下: int MessageBox( LPCTSTR lpszText, LPCTSTR lpszCaption = NULL, UINT nType = MB_OK );..._仿afxmessagebox

推荐文章

热门文章

相关标签