修改apache配置文件:httpd.conf
- 搜索’Define SRVROOT’, 查看cgi根目录,python脚本需要放在该
Define SRVROOT "D:/Program/phpstudy_pro/Extensions/Apache2.4.39 - 解决中文乱码
文件最后添加AddDefaultCharset gbk
重启apache
python脚本:
#!python
# -*- coding: utf-8 -*-print ("Content-type:text/html")
print () # 空行,告诉服务器结束头部
print ('<html>')
print ('<head>')
print ('<meta charset="utf-8">')
print ('<title>Hello Word - 我的第一个 CGI 程序!</title>')
print ('</head>')
print ('<body>')
print ('<h2>Hello Word! 我是来自菜鸟教程的第一CGI程序2222</h2>')
print ('</body>')
print ('</html>')