0

Does anyone know of a way to represent Non-ASCII symbols such as this symbol "ŷ" on python in a print statement?

Cole Tobin
  • 9,206
  • 15
  • 49
  • 74
user3720526
  • 123
  • 1
  • 1
  • 7

1 Answers1

-1

You should use the UTF-8 coding system.

The first line of your Python file should be:

# -*- coding: utf-8 -*-

If this doesn't work, try wrapping your string with unicode(string).

print unicode("éáóý");

If this still doesn't work, try adding these lines before all code but after # -- coding: utf-8 --

import sys
if not hasattr(sys, "setdefaultencoding"):
    reload(sys)
sys.setdefaultencoding("utf-8")

Finally, make sure that you are saving the file as UTF-8 and that your console supports unicode characters.

Zenadix
  • 15,291
  • 4
  • 26
  • 41