在python中使用Malayalam字符编码

2024-06-16 10:43:10 发布

您现在位置:Python中文网/ 问答频道 /正文

代码:

import unicodedata
s=u'കക'
b=s.encode('utf-8').decode('utf-8')
print(b)

在python3.0shell中生成了正确的输出,如。但当我在Spyder(Python2.7)(设置为默认编码方案utf-8)中尝试相同的方法时,它显示错误如下:

^{pr2}$

请提供解决方案。在


Tags: 方法代码import错误解决方案shellutfencode
1条回答
网友
1楼 · 发布于 2024-06-16 10:43:10

下面的代码在Ubuntu14.04和Python2.7.6中生成正确的输出

#!/usr/bin/python
# -*- coding: utf_8 -*-
import unicodedata
s=u'കക'
b=s.encode('utf-8').decode('utf-8')
print(b)

കക

相关问题 更多 >