我是 web2py 的新手。我有一个表(表单),在我的 python 脚本中我想使用特定的字段值。
def GetData()
return request.vars.values()
此函数为我提供了所有字段,但我想知道如何从表单中获取“input1”(例如)字段的值。
表格:
<form action="GetData" enctype="multipart/form-data" id="formId" method="post"
name="formId">
<table>
<tr id="field1">
<input id="input1" name="input1" type="text" value="" />
</tr>
<tr id="field2">
<input id="input2" name="input2" type="text" value="" />
</tr>
<tr id="field3">
<input type="submit" value="Submit" />
</tr>
</table>
</form>
谢谢!!!
来自 web2py book
The request object is an instance of the ubiquitous web2py class that is called gluon.storage.Storage, which extends the Python dict class. It is basically a dictionary, but the item values can also be accessed as attributes:
这就是您所需要的。
p = request.vars['p']
q = request.vars['q']
我是一名优秀的程序员,十分优秀!