how to print the GREEK CAPITAL LETTER delta under utf-8 encoding

"Martin v. Lo"wis" martin at v.loewis.de
Tue May 29 01:34:01 EDT 2007


人言落日是天涯,望极天涯不见家 schrieb:
> I lookup the utf-8 form of delta from the link.
> http://www.fileformat.info/info/unicode/char/0394/index.htm
> 
> and then I want to print it in the python ( I work under windows)
> 
> #!/usr/bin/python
> #coding=utf-8
> 
> print "\xce\x94"
> 
> but the result is not the 'delta' but an unknown character.

I assume you print to the terminal (cmd.exe). This cannot work;
the terminal (usually) does not interpret the characters in UTF-8.
Instead, you should print a Unicode string, e.g.

print u"\N{GREEK CAPITAL LETTER DELTA}"

or

print u'\u0394'

This should work as long as your terminal supports printing
the letter at all.

Regards,
Martin



More information about the Python-list mailing list