Python - cgi字段存储错误

时间:2015-11-11 23:54:37

标签: python post cgi

我在我的python脚本中有这个

form = cgi.FieldStorage()
print form
print form.getvalue("param")

第二行打印FieldStorage(None, None, 'param=abcd'),第三行导致错误

    File "/var/www/cgi-bin/use_save.py", line 24, in <module>
    print form.getvalue("param")
  File "/usr/lib64/python2.7/cgi.py", line 548, in getvalue
    if key in self:
  File "/usr/lib64/python2.7/cgi.py", line 594, in __contains__
    raise TypeError, "not indexable"
    TypeError: not indexable

导致此错误的原因是只传递一个字符串的值?

1 个答案:

答案 0 :(得分:0)

尝试将表单的enctype更改为multipart/form-dataapplication/x-www-form-urlencoded

此处提供更多信息:http://www.futurequest.net/forums/showthread.php?t=14245

http://www.w3schools.com/tags/att_form_enctype.asp