使用cgi python在textarea中找到一个单词

时间:2016-09-19 17:55:36

标签: python html cgi cgi-bin

如何在表单上的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>"

0 个答案:

没有答案