代码拉取完成,页面将自动刷新
#!/usr/bin/python3.4
debugme = False
inputkey = 'language'
hellos = {
'Python': r" print('Hello World') ",
'Python2': r" print 'Hello World' ",
'Perl': r" print 'Hello World\n'; ",
'Tcl': r" puts 'Hello World' ",
'Java': r" System.out.println ('Hello World'); ",
'C': r" printf ('Hello World\n'); ",
'C++': r" cout << 'Hello World' << endl; "
}
class dummy:
def __init__(self, str): self.value = str
import cgi, sys
if debugme:
# print(debugme)
form = {inputkey: dummy(sys.argv[1])}
else:
form = cgi.FieldStorage()
print("Content-type: text/html\n")
print("<TITLE>Languages</TITLE>")
print("<H1>Syntax</H1><HR>")
def showHello(form):
choice = form[inputkey].value
print("<H3>%s</H3><P><PRE>" % choice)
try:
# print(form)
print(cgi.escape(hellos[choice]))
except KeyError:
print("Sorry -- I don'not Know that language")
print("</PRE></P><BR>")
if not inputkey in form or form[inputkey].value == 'ALL':
for lang in hellos.keys():
mock = {inputkey: dummy(lang)}
showHello(mock)
else:
showHello(form)
print("<HR>")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。