+ -
当前位置:首页 → 问答吧 → apache+python32出错记录

apache+python32出错记录

时间:2011-07-03

来源:互联网

刚才配置了一个apache+python32环境(windowsxp),写了一个例子:
  1. #!C:/Python32/python.exe
  2. print ("Content-type: text/html")print
  3. print ("<h1>Hello python</h1>")
复制代码
执行时发生500错误,看errorlog,得到信息如下:


QUOTE:
[Sun Jul 03 13:14:04 2011] [error] [client 127.0.0.1] malformed header from script. Bad header=<h1>Hello python</h1>: hello.py


上网一查,找到了原因:http://www.daniweb.com/software-development/python/threads/326384
  1. print "Content-Type: text/html\n"
复制代码
问题解决。

作者: renxiao2003   发布时间: 2011-07-03

另外,python的print方法,字符串要加到()里,如print ("hello"),而不能用print "hello"
这个不知道是windows原因还是python32原因。

作者: renxiao2003   发布时间: 2011-07-03

刚才试了一下,加()应该是python32版本的原因。

作者: renxiao2003   发布时间: 2011-07-03