如何检查请求POST中是否存在值?

Age*_*lla 2 python flask python-2.7

我使用POST方法提交表单.表单有一个输入字段:time.

我试着检查是否存在参数:

if 'time' in request.data:
   pass
Run Code Online (Sandbox Code Playgroud)

但它不起作用

zwe*_*wer 8

request.form如果您将数据作为常规POST正文查询发布,则应该使用,即:

@app.route('/schedule/<int:adv_id>', methods=['POST'])
def schedule(adv_id):
    if "time" in request.form:
        pass  # do whatever you want with it
Run Code Online (Sandbox Code Playgroud)