普通的python字符串使用什么编码? [英] What encoding do normal python strings use?

查看:24
本文介绍了普通的python字符串使用什么编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 django 在整个框架中使用 unicode 字符串而不是普通的 python 字符串.正常的python字符串使用什么编码?为什么他们不使用 unicode?

i know that django uses unicode strings all over the framework instead of normal python strings. what encoding are normal python strings use ? and why don't they use unicode?

推荐答案

从 Python 3.0 开始,所有字符串默认都是 unicode,还有 bytes 数据类型(Python 文档).

From Python 3.0 on all strings are unicode by default, there is also the bytes datatype (Python documentation).

因此python开发人员认为使用unicode是一个好主意,它在python 2中没有普遍使用主要是由于向后兼容性.它还具有性能影响.

So the python developers think that using unicode is a good idea, that it is not used universally in python 2 is mostly due to backwards compatibility. It also has performance implications.

这篇关于普通的python字符串使用什么编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆