这段代码让人怀念刚学jdbc的时候
#!/usr/bin/pythonimport MySQLdbprint "Content-Type: text/html"printprint "<html><head><title>Books</title></head>"print "<body>"print "<h1>Books</h1>"print "<ul>"connection = MySQLdb.connect(user='root', passwd='haoning', db='test')cursor = connection.cursor()cursor.execute("select question from polls_poll ORDER BY pub_date DESC LIMIT 10")for row in cursor.fetchall(): print "<li>%s</li>" % row[0]print "</ul>"print "</body></html>"connection.close()