<p>
<select name='type'>
<option>Only Names</option>
<option>Only Numbers</option>
</select>
</p>
如果我要制作一个 Python 脚本,并在选择 Only Names 的情况下搜索名称,我将如何去做呢?就像我会在我的 python 脚本中输入什么?我现在脑海中的例子:
if form == Only Names:
print stuff
应评论要求添加更多信息:
import cgi
form = cgi.FieldStorage()
from file import *
f = File("lists.data")
if f.exists() == True:
f.startRead()
list = f.read()
f.close()
print "<h1>Catalog</h1>"
print "<ul>"
sequel2 = variables.find ("2")
sequel3 = variables.find ("3")
superheroMan = variables.find ("man")
superheroWoman = variables.find ("woman")
superheroBoy = variables.find ("person")
for variable in list:
if NEED TO KNOW THIS PART
print "<li>" + variable + "</li>"
print "</ul>"
else:
print "<p>Error: No saved data found.</p>"
这是我的表格:
<p>Lists to display:</p>
<div>
<select name='type'>
<option>Only Names</option>
<option>Only Numbers</option>
</select>
</div>
<p><input type='submit' value='Display'></p>
</form>