Can't print Chinese to HTTP

Ned Deily nad at
Mon Nov 30 20:00:12 CET 2009

In article 
<e60da505-ac24-4307-b82e-9257de0fa690 at>,
 Gnarlodious <gnarlodious at> wrote:

> It does work in Terminal interactively, after I import the sys module.
> But my script doesn't act the same. Here is my entire script:
> #!/usr/bin/python
> print("Content-type:text/plain;charset=utf-8\n\n")
> import sys
> sys.stdout.buffer.write('ùÁÄn'.encode("utf-8"))
> All I get is the despised "Internal Server Error" with Console
> reporting:
> malformed header from script. Bad header=Äxe6Äx99Äx89
> Strangely, if I run the script in Terminal it acts as expected.
> This is OSX 10.6 2,, Python 3.1.1.

Are you sure you are actually using Python 3?  /usr/bin/python is the 
path to the Apple-supplied python 2.6.1.  If you installed Python 3.1.1 
using the OS X installer, the path should be 

 Ned Deily,
 nad at

More information about the Python-list mailing list