“简单胜于复杂”,提姆·彼得斯,蟒蛇之禅
utf8forgood的Python项目详细描述
utf8forgood
----
**厌倦了python的“unicodedeocodeerror”,ascii编码无法解码?`**
以下是如何一次性修复的方法。
1.`$pip安装utf8forgood`
2。在主程序中,添加
```
import utf8forgood
````
运行“python-m site”或阅读[site-specific configuration hook][8]。
为什么?
----
一般来说,最快的补救方法可能是按以下顺序尝试:
1。使用'pytonioencoding=utf-8 python/path/to/program.py`
2。使用[`sys.setDefaultEncoding`][1]黑客。也就是说,除非你在乎别人说什么。编写您自己的导入函数以[适当地转换数据][3],这通常是[推荐的方法][4]。
http://stackoverflow.com/a/17628350/890242
[2]:http://stackoverflow.com/questions/28657010/dangers-of-sys-setdefaultencodingutf-8
[3]:http://stackoverflow.com/a/28760303/890242
[4]:http://stackoverflow.com/a/34378962/890242
[5]:http://stackoverflow.com/a/29558302/890242
[6]:http://stackoverflow.com/a/29561747/890242
[7]:http://stackoverflow.com/a/27745947/890242
[8]:https://docs.python.org/2/library/site.html
----
**厌倦了python的“unicodedeocodeerror”,ascii编码无法解码?`**
以下是如何一次性修复的方法。
1.`$pip安装utf8forgood`
2。在主程序中,添加
```
import utf8forgood
````
运行“python-m site”或阅读[site-specific configuration hook][8]。
为什么?
----
一般来说,最快的补救方法可能是按以下顺序尝试:
1。使用'pytonioencoding=utf-8 python/path/to/program.py`
2。使用[`sys.setDefaultEncoding`][1]黑客。也就是说,除非你在乎别人说什么。编写您自己的导入函数以[适当地转换数据][3],这通常是[推荐的方法][4]。
http://stackoverflow.com/a/17628350/890242
[2]:http://stackoverflow.com/questions/28657010/dangers-of-sys-setdefaultencodingutf-8
[3]:http://stackoverflow.com/a/28760303/890242
[4]:http://stackoverflow.com/a/34378962/890242
[5]:http://stackoverflow.com/a/29558302/890242
[6]:http://stackoverflow.com/a/29561747/890242
[7]:http://stackoverflow.com/a/27745947/890242
[8]:https://docs.python.org/2/library/site.html