/ / Utilisation de Malayalam unicode en python - python, unicode, codage de caractères, python-unicode

Utilisation de Malayalam unicode en python - python, unicode, encodage de caractères, python-unicode

Le code:

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

produit une sortie correcte dans le shell Python 3.0 കക. Mais quand j'ai essayé la même chose dans Spyder (Python 2.7) (Définir comme schéma de codage par défaut utf-8), il a montré une erreur comme:

return codecs.charmap_encode(input,errors,encoding_table) UnicodeEncodeError: "charmap" codec can"t encode characters in position 0-1: character maps to <undefined>

veuillez fournir une solution.

Réponses:

3 pour la réponse № 1

Le code suivant produit une sortie correcte dans Ubuntu 14.04 et Python 2.7.6

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

കക