当前位置: 代码迷 >> 综合 >> NameError: name ‘requests‘ is not defined和NameError: name ‘request‘ is not defined
  详细解决方案

NameError: name ‘requests‘ is not defined和NameError: name ‘request‘ is not defined

热度:80   发布时间:2024-02-23 11:59:11.0

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

  相关解决方案