How to use UTF-8 in Python

来源:互联网 发布:360杀毒mac版靠谱吗 编辑:程序博客网 时间:2024/05/20 19:30

http://stackoverflow.com/questions/6289474/working-with-utf-8-encoding-in-python-source

In source header you can declare:

#!/usr/bin/env python# -*- coding: utf-8 -*-....

It is described in the PEP 0263:

Then you can use UTF-8 in strings:

#!/usr/bin/env python# -*- coding: utf-8 -*-u = 'idzie wąż wąską dróżką'uu = u.decode('utf8')s = uu.encode('cp1250')print(s)

0 0
原创粉丝点击