NameError: name ‘requests’ is not defined是缺少包import requests
;
NameError: name ‘request’ is not defined是缺少包from flask import request
。
这俩长太像了,但作用不一样。“requests”是用来获取GET,POST请求等,如
r = requests.get('https://api.github.com/user', auth=('user', 'pass'))
“request”是用来获取表单数据如
request.form.get("value")
,或者前端请求方式等等,更具体请查flask 中的request
参考:
Requests: 让 HTTP 服务人类
NameError: name ‘request’ is not defined