How to use UTF-8 in Python
2014-05-12 13:44
393 查看
http://stackoverflow.com/questions/6289474/working-with-utf-8-encoding-in-python-source
In source header you can declare:
It is described in the PEP 0263:
Then you can use UTF-8 in strings:
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)
相关文章推荐
- How can I force Python's file.write() to use the same newline format in Windows as in Linux (“\r\n”
- How to use FTP in Python
- How to Use UTF-8 with Python python中使用utf-8
- [Python]How to use magic methods in Python?
- How to use *args and **kwargs in Python
- How to properly use relative or absolute imports in Python modules? - Stack Overflow
- 如何在python中使用*args,**kwargs (How to use *args and **kwargs in Python)
- 《How to Use the TimeDistributed Layer for Long Short-Term Memory Networks in Python》学习笔记
- How-to use MySQL-python in Python
- How to use *args and **kwargs in Python
- How to Use the TimeDistributed Layer for Long Short-Term Memory Networks in Python 译文
- how to use pandas in python
- How to use SET in python
- [zz]How to use *args and **kwargs in Python
- how to use Decimal by default instead of float in python
- HOWTO Use Python in the web — Python v3.0.1 documentation
- How to use sharepoint webservices in web application
- Learn how to Use UIPageViewController in iOS
- How to use use zip/unzip in java?
- How to install opencv in python