问题
Does anyone know of a way to represent Non-ASCII symbols such as this symbol "ŷ" on python in a print statement?
回答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.
来源:https://stackoverflow.com/questions/24112984/is-it-possible-to-represent-non-ascii-characters