1 Star 0 Fork 45

张鹏/qytang_Python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
2016.1.28 安全试验台自动化 python 881 Bytes
一键复制 编辑 原始数据 按行查看 历史
现任明教教主-乾颐堂 提交于 2016-01-28 10:45 . new file
#!/usr/bin/python3.4
import cgi, sys
form = cgi.FieldStorage()
print("Content-type: text/html")
#class dummy:
# def __init__(self, s): self.value = s
#form = {"yourname" : dummy("qinke"), "rack" : dummy("bjrack01"), "youraction" : dummy("clearrack")}
html = """
<TITLE>乾颐堂安全试验台自动脚本</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<H1>问候语</H1>
<HR>
<H4>你的姓名是 %(yourname)s</H4>
<H4>你选择的试验台是 %(rack)s</H4>
<H4>你选择的操作是 %(youraction)s</H4>
<HR>"""
data = {}
for field in ("yourname", "rack", "youraction"):
if not field in form:
data[field] = "(未知)"
else:
if not isinstance (form[field], list):
data[field] = form[field].value
else:
values = [x.value for x in form[field]]
data[field] = " and ".join(values)
print(html % data)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/networker-python/qytang_Python.git
git@gitee.com:networker-python/qytang_Python.git
networker-python
qytang_Python
qytang_Python
master

搜索帮助