本文介绍了在Python 2.7中打印带重音符号的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是python的新手。我正在尝试打印带重音的字符,例如:
I'm new to python. I'm trying to print accented characters, like this:
# -*- coding: utf-8 -*-
print 'éàÇÃãéèï'
但是执行此代码时,我得到:
But when I execute this code, I get:
>> ├®├á├ç├â├ú├®├¿├»
我正在使用64位Windows 7& Python 2.7.5,我在 file.py
中有代码,并使用
I'm using 64-bit Windows 7 & Python 2.7.5, I have the code in file.py
and execute it with
python file.py
推荐答案
如Wooble所述,如果您更改
As Wooble mentioned, if you change
print 'éàÇÃãéèï'
至
print u'éàÇÃãéèï'
应该工作。
这是python中unicode的一个很好的介绍(两者对于2.x和3):
Here is a good intro to unicode in python (both for 2.x and 3):The updated guide to unicode
这篇关于在Python 2.7中打印带重音符号的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!