python笔试题 github_python requests库面试笔试题

1 为什么requests库很重要?

A. 提供一个清晰简洁的框架来处理HTTP请求。

B. 抽象HTTP协议的复杂部分。

C. Python中发出HTTP请求的事实上的标准。

D. 它是在Python中建立HTTP连接的唯一可用选项。

2 服务器响应客户端请求发出HTTP状态代码。找出错误项:

A. 5xx Server Error

B. 2xx Success

C. 3xx Redirection

D. 1xx Error

E. 4xx Client Error

3 以下哪些HTTP请求正确?

B. requests.put('https://httpbin.org/put', data={'key':'value'})

4 以下代码的执行结果是?

import requests

from requests.exceptions import HTTPError

url = 'https://httpbin.org/'

try:

response = requests.get(url)

# If the response was successful, no Exception will be raised

response.raise_for_status()

except HTTPError as http_err:

print(f'HTTP error occurred: {http_err}')

except Exception as err:

print(f'Other error occurred: {err}')

else:

print('Success!')

A. Other error occured

B.Success!

C.HTTP error occurred: 404 Client Error: NOT FOUND for url: https://httpbin.org/

参考资料

5 关于response = requests.get('https://api.github.com')的正确描述有:

A. response.content returns the response content as a string object.

B.response.text returns the response content as a string object.

C.response.text returns the response content as a bytes object.

D.response.json() returns the response content as a json object.

E.response.json returns the response content as a json object.

F.response.content returns the response content as a bytes object.

374dca87802b?hmsr=toutiao.io

demo.png

6 以下哪些认证的代码是正确的?

A. requests.get('https://httpbin.org/get', auth=customClassForAuthentication('self_generated_token'))

B.requests.get('https://api.github.com/user', auth=('username', getpass()))

D.requests.get('https://api.github.com/user', auth=HTTPBasicAuth('username', getpass()))

7 以下哪些和性能无关?

A. Max Retries

B.Timeouts

C. Logging

D.Session Objects

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值