[英]Python Pass List to CGI
In Python CGI, is it possible pass "Python list" as hidden text input field ? 在Python CGI中,是否可以将“ Python列表”作为隐藏文本输入字段传递? How can I retrieve values using cgi form later ? 以后如何使用cgi form检索值?
Thanks for help. 感谢帮助。
def testinput2(answer):
#answer=['a','b','a','a','a']#according to abc1 statefile
fin = file("2.map", "r")
for line in fin.readlines():
fun.append(line.strip().split(','))
fin.close()
print "<br>Action Traversal\t", answer
for id,val in enumerate(answer):
if id < 1:
first(fun,val)
else:
secondandon(fun,val)
print "<br><FORM ACTION=\"/cgi-bin/bul.py\" METHOD=\"POST\"><input type=\"hidden\" name=\"nxtans\" value=\"%s"%answer,"\"><input type=\"text\" name=\"nxtv\" value=\"\"><INPUT TYPE=SUBMIT VALUE=\"Next State Click\"></FORM><br><br>"
No, HTML elements only support one value per an input
element and know nothing of Python lists. 不,HTML元素每个input
元素仅支持一个值,而对Python列表一无所知。
If you want to save a list of values in html, you should create list of hidden HTML inputs, each with the same name
attribute. 如果要使用html保存值列表,则应创建隐藏的HTML输入列表,每个输入均具有相同的name
属性。
You can later get the list of values with form.getvalue(key)
, where the key
is the value of the name
attribute. 您稍后可以使用form.getvalue(key)
获得值列表,其中key
是name
属性的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.