cgi字段存储python

时间:2019-02-21 18:36:14

标签: python cgi

我创建了一个脚本,该脚本将提取文本字段的字段值和单选按钮值。脚本会正确提取这些值,并相应地发布数据。我在脚本中添加了textarea字段,但是在发布textarea值时,它将显示文本字段,单选按钮和textarea的所有值。我想念什么吗?

下面是代码:

def htmlValue():
    form =cgi.FieldStorage()
    notes = form.getvalue('notes')
    fname = form.getvalue('fname')
    lname = form.getvalue('lname')
    name = fname+" "+lname
    desk = form.getvalue('desk')
    con = form.getvalue('con')
    sys = form.getvalue('sys')

    return form, notes, fname, lname, desk, con, sys

def htmlBody(form, notes, fname, lname, desk, con, sys)
    ....
    print """<tr><td>Notes</td><td>"""
    print "%s" % notes
    print """</td></tr>"""
    ....

HTML页面:

def htmlBody():
    ....
    <tr>
    <td><textarea class="form-control" name="notes" id="notes" rows="5" placeholder="Notes"></textarea></td>
    </tr>

输出:

FieldStorage(None, None, [MiniFieldStorage('fname', 'test'), MiniFieldStorage('lname', 'test'), MiniFieldStorage('desk', 'Pass'), MiniFieldStorage('con', 'Pass'), MiniFieldStorage('sys', 'Pass'), MiniFieldStorage('notes', 'test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test ')])

0 个答案:

没有答案