gpt4 book ai didi

python - 使用 web2py 检索表字段

转载 作者:太空宇宙 更新时间:2023-11-03 18:52:28 25 4
gpt4 key购买 nike

我是 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']

关于python - 使用 web2py 检索表字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18021170/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com