#!/usr/bin/python
# Import modules for CGI handling
import cgi, cgitb
# Create instance of FieldStorage
form = cgi.FieldStorage()
name = form.getvalue('name')
age = int(form.getvalue('age')) + 1
print "Content-type: text/html"
print
print "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">"
print "<html>"
print "<head><title></title></head>"
print "<body>"
print "<p> Hello, %s</p>" % (name)
print "<p> Next year, you will be %s years old.</p>" % age
print "</body>"
print "</html>"
每當我寫下DOCTYPE時,都會出現無效語法錯誤。不知道問題是什麼。因爲我是python的新手,所以很感謝。謝謝!Python DOCTYPE語法錯誤
當你打印你得到一個錯誤「!DOCTYP ......」 ?您可能想用逗號分隔這些內容,或者避開引號。 – sihrc