Can't print Chinese to HTTP
Terry Reedy
tjreedy at udel.edu
Tue Dec 1 17:06:18 EST 2009
Gnarlodious wrote:
> On Dec 1, 8:36 am, Lie Ryan wrote:
>
>> #!/usr/bin/python
>> import sys
>> print = lambda s: sys.stdout.buffer.write(s.encode('utf-8'))
This is almost exactly the same as
def print(s): return sys.stdout.buffer.write(s.encode('utf-8'))
except that the latter gives better error tracebacks.
>> print("Content-type:text/plain;charset=utf-8\n\n")
>> print('晉\n')
>
> HA! IT WORKS! Thank you thank you thank you. I don't understand the
> lambda functionality but will figure it out.
Nothing to do with lambda, really. See above.
tjr
More information about the Python-list
mailing list