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

  • Post author:
  • Post category:其他


NameError: name ‘request

s

’ 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



版权声明:本文为ninitiange2原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。