如何在列表中打印德语变音符?

时间:2019-03-20 12:11:48

标签: python python-2.7 python-unicode

在我看来,python打印无法在列表,字典和元组中打印德语变音符号。我该如何更改?

# -*- coding: cp1252 -*-
print 'ÄÖÜ' #'ÄÖÜ'

x = 'ÄÖÜ'
print x #'ÄÖÜ'

x = ['ÄÖÜ',]
print x #['\xc4\xd6\xdc']
print x[0] #'ÄÖÜ'

x = [u'ÄÖÜ',]
print x #['\xc4\xd6\xdc']
print x[0] #'ÄÖÜ'

x = {'Ä': 'Ü'}
print x #{'\xc4': '\xdc'}
print x['Ä'] #'Ü'

1 个答案:

答案 0 :(得分:-2)

将编码更改为此:

# -*- coding: cp852 -*-