Ci-dessous, les différences entre deux révisions de la page.
— |
tips_informatiques:programmation:python:unicode [2013/10/29 12:53] (Version actuelle) nico créée |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ====== Unicode ====== | ||
+ | ===== 2.7 ===== | ||
+ | |||
+ | * Python byte strings (str type) have an encoding, Unicode does not | ||
+ | |||
+ | |||
+ | <code python> | ||
+ | ''' | ||
+ | encode(encoding) convert an unicode to a string encoded in 'encoding' charset | ||
+ | ''' | ||
+ | my_string = my_unicode.encode(encoding) | ||
+ | </code> | ||
+ | |||
+ | |||
+ | <code python> | ||
+ | ''' | ||
+ | decode(encoding) convert a string encoded in 'encoding' charset to an unicode | ||
+ | ''' | ||
+ | my_unicode = my_string.decode(encoding) | ||
+ | </code> |