- 论坛徽章:
- 0
|
手册上是这样写的:
Set the current default string encoding used by the Unicode implementation. If name does not match any available encoding, LookupError is raised. This function is only intended to be used by the site module implementation and, where needed, by sitecustomize. Once used by the site module, it is removed from the sys module's namespace.
仔细看/usr/lib/python2.4下的site.py文件,该模块在没有以python -S运行时是自动导入的,目的是将一些第三方的packages目录加到sys.path中。在site导入过程中,通过读取locale,取得默认编码,然后将setdefaultencoding方法从sys命名空间中删除。 |
|