- 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请求正确?
A. requests.post('https://httpbin.org/post', data={'key':'value'})
B. requests.put('https://httpbin.org/put', data={'key':'value'})
C. requests.delete('https://httpbin.org/delete')
D. requests.tail('https://httpbin.org/tail')
- 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.
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()))
C. requests.get('https://api.github.com/user')
D.requests.get('https://api.github.com/user', auth=HTTPBasicAuth('username', getpass()))
- 7 以下哪些和性能无关?
A. Max Retries
B.Timeouts
C. Logging
D.Session Objects
网友评论