python - 使用 web2py 检索表字段

标签 python web2py

我是 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/

相关文章:

python - 之后改变输入运算符会影响之前方程的乘积吗?

python - 痛饮和 python3 : surplus underscore

python - 在 Google App Engine 上使用自定义域进行 Web2py 身份验证?

ssl - Raspberry pi 家庭自动化项目 : issue with web2py

python - 编译 Cython 扩展错误 - Pycharm IDE

python - Python中多元函数的向量化偏导数

python koan - 将这两个衬里简化为一个

python - 在 Python 应用程序中,无法找到项目的来源

python - Selenium 从字典中选择带有 for 循环的下拉选项

templates - 更改 ember.js 中的默认分隔符