关于默认编码的错误想法
encodingcontext的Python项目详细描述
Although practicality beats purity.Errors should never pass silently.Unless explicitly silenced.—Zen of Python
这个小模块实现了一个坏主意:使用默认编码 明确范围:
>>> withencoding_context('euc-kr'):... str(u'\ud55c\uae00')...'\xc7\xd1\xb1\xdb'
当然有几个缺点,最关键的是: 在thread、threading、greenlet、tasklet等中使用 可能破坏了它的范围。如果python具有动态作用域和默认值 编码被定义为动态作用域变量,我们可能有更多 在Unicode字节字符串之间进行编码的便捷方法。