我对 Python 已经很熟悉了,现在我正在寻找一个基本的 Web 应用程序。我有点害怕 Django 和其他 Python 框架,所以我对它进行了深入研究,并决定使用另一个 Python 脚本自己生成 HTML。
也许这就是你的做法——但我只是在弄清楚这些东西。我真的在寻找关于下一步该做什么的提示。
我的 Python 脚本打印 HTML(这是否正确?我需要它出现在网页上!),但现在呢?
感谢您在我学习过程中一直以来的支持。总有一天我会发布答案!
-泰勒
这是我的代码:
from SearchPhone import SearchPhone
phones = ["Iphone 3", "Iphone 4", "Iphone 5","Galaxy s3", "Galaxy s2", "LG Lucid", "LG Esteem", "HTC One S", "Droid 4",
"Droid RAZR MAXX", "HTC EVO", "Galaxy Nexus", "LG Optimus 2", "LG Ignite",
"Galaxy Note", "HTC Amaze", "HTC Rezound", "HTC Vivid", "HTC Rhyme", "Motorola Photon",
"Motorola Milestone", "myTouch slide", "HTC Status", "Droid 3", "HTC Evo 3d", "HTC Wildfire",
"LG Optimus 3d", "HTC ThunderBolt", "Incredible 2", "Kyocera Echo", "Galaxy S 4g",
"HTC Inspire", "LG Optimus 2x", "Samsung Gem", "HTC Evo Shift", "Nexus S", "LG Axis", "Droid 2",
"G2", "Droid x", "Droid Incredible"
]
print """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>table of phones</title>
</head>
<body>
</body>
</html>
"""
#table
print '<table width="100%" border="1">'
for x in phones:
y = SearchPhone(x)
print "\t<tr>"
print "\t\t<td>" + str(y[0]) + "</td>"
print "\t\t<td>" + str(y[1]) + "</td>"
print "\t\t<td>" + str(y[2]) + "</td>"
print "\t\t<td>" + str(y[3]) + "</td>"
print "\t\t<td>" + str(y[4]) + "</td>"
print "\t</tr>"
print "</table>"