小编Cap*_* in的帖子

如何使用 python 瓶从 FormsDict 检索数据?

我无法打印结果。如果我使用,这在烧瓶上工作正常,result= request.form然后print(result). 这会在烧瓶上打印字典。但使用瓶子不起作用。当我使用type(result)它时说<class 'bottle.FormsDict'>

x.py 文件:

from bottle import request, template,route,run,post

@route('/')
def index():
    return template('val.html')

@post('/result')
def result():
    result=request.forms
    print(result)       #Unable to print 

if __name__ == '__main__':
    run(host='localhost',port=8080,debug='True',reloader='True')
Run Code Online (Sandbox Code Playgroud)

val.html 文件:

<!DOCTYPE html>
<html>
<body>

<form action="http://localhost:8080/result" method = "POST">
Select a time:
<input type="time" name="usr_time">
<br> <br>
<input type="checkbox" name="A" value="A is on" >A </input>
<br>
<input type="checkbox" name="B" value="B is on" >B </input>
<br>
<input type="checkbox" name="C" value="C is on" >C …
Run Code Online (Sandbox Code Playgroud)

python httpresponse request bottle python-3.x

2
推荐指数
1
解决办法
1510
查看次数

标签 统计

bottle ×1

httpresponse ×1

python ×1

python-3.x ×1

request ×1