2016-12-27 29 views

回答

0

简而言之,编码就是将数据存储在内存中。不同的方式,允许更多的字符和信息。对于深入说明你非常欢迎阅读或者http://kunststube.net/encoding/,或Wikipedia

在Python中,你可以改变的事情是通过物理地调用编码类型,或使用任何的the coding function存储的方式。

对于您的python3.x环境,sys.stdout.encodingsys.getdefaultencoding()之间没有区别。他们都使用8位代码单位(最标准)。虽然优选编码locale.getpreferredencoding()cp1252)是latin1的Windows版本。

请注意,如果您想通过任何方法/功能获得快速反馈,您可以随时使用help命令。

实施例:

>>> import locale 
>>> help(locale.getpreferredencoding) 

输出:

Help on function getpreferredencoding in module locale: 

getpreferredencoding(do_setlocale=True) 
    Return the charset that the user is likely using, 
    according to the system configuration. 
(END)