如何在表单上的textarea中获取单词并将其排序? EX:
输入:
tes1,tes2,tes3
结果:
TES1
TES2
tes3
HTML
<form action="http://localhost/getword.py" method="post" >
<textarea name="textcontent" cols="40" rows="4"></textarea>
<input type="submit" value="Submit" />
</form>
CGI Py
#!/usr/bin/python
import cgi, cgitb
form = cgi.FieldStorage()
if form.getlist('textcontent'):
text_content = form.getvalue('textcontent').replace(',','\n')
else:
text_content = "Not entered"
print "Content-type:text/html\r\n\r\n"
print "<html>"
print "<head>";
print "<title>Text Area - Fifth CGI Program</title>"
print "</head>"
print "<body>"
print "<h2>%s</h2>" % text_content
print "</body>"