我使用python在本地服务器(通过XAMPP的Apache服务器)上运行python脚本。最初,脚本显示在文本编辑器上。我使用的代码是-
#!C:\Users\Gaurav Rai\AppData\Local\Programs\Python\Python37-32\python.exe
def htmlTop():
print("""
Content-Type: text/html
<!Doctype html>
<html lang=en>
<head>
<meta charset="UTF-8">
<title>My First Server Page in Python</title>
</head>
<body>
""")
def htmlTail():
print("""
</body>
</html>
""")
if __name__== "__main__" :
try:
htmlTop()
print("""<h1>Hello World!</h1>""")
htmlTail()
except:
cgi.print_exception()
即将到来的产出是- enter image description here
在得到-Running Python scripts with Xampp的帮助后
我把密码改成-
def htmlTop():
print("""Content-Type: text/html""")
print("""
<!Doctype html>
<html lang=en>
<head>....(remaining code is same)
在做了这个更改之后,代码运行良好,并且需要输出“helloworld!”已在本地服务器上获取
有人能解释一下这里到底发生了什么吗
目前没有回答
相关问题 更多 >
编程相关推荐