#!G:/python3.6/python.exe
# -*- coding: UTF-8 -*-
print("Content-type:text/html")
print() # 空行,告诉服务器结束头部
print('<html>')
print('<head>')
print('<meta charset="utf-8">')
print('<title>HelloCGI Program!</title>')
print('</head>')
print('<body>')
print('<h2>Hello Word! CGI PROGRAM为什么有乱码</h2>')
print('</body>')
print('</html>')
结果,网页中文和标题中文都会出现乱码
解决方法:
注释掉 print(’’),就好了
#!D:\program files\python\python.exe
#!G:/python3.6/python.exe
# -*- coding: UTF-8 -*-
print("Content-type:text/html")
print() # 空行,告诉服务器结束头部
print('<html>')
print('<head>')
# print('<meta charset="utf-8">') # 要有空格
print('<title>HelloCGI Program!</title>')
print('</head>')
print('<body>')
print('<h2>Hello Word! CGI PROGRAM为什么有乱码</h2>')
print('</body>')
print('</html>')
Hello Word! CGI PROGRAM为什么有乱码