最基本的hello world
#!/usr/bin/python
print "Content-type: text/html"
print "hello world"
聪明一些的hello world
#!/usr/bin/python
import cgi
print "Content-type: text/html"
form = cgi.FieldStorage()
to = form['to'].value
print "hello " + to
本文通过两个示例介绍了如何使用 Python 的 CGI 模块来创建简单的 Web 应用程序。第一个示例展示了一个最基本的 helloworld 程序,第二个示例则展示了如何接收并处理来自网页表单的数据。
最基本的hello world
#!/usr/bin/python
print "Content-type: text/html"
print "hello world"
聪明一些的hello world
#!/usr/bin/python
import cgi
print "Content-type: text/html"
form = cgi.FieldStorage()
to = form['to'].value
print "hello " + to

被折叠的 条评论
为什么被折叠?