Python 字符串中的 u 前缀是什么? [英] What's the u prefix in a Python string?

查看:48
本文介绍了Python 字符串中的 u 前缀是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

喜欢:

u'Hello'

我的猜测是它表示Unicode",对吗?

My guess is that it indicates "Unicode", is it correct?

如果有,从什么时候开始可用?

If so, since when is it available?

推荐答案

你说得对,见 3.1.3.Unicode 字符串.

You're right, see 3.1.3. Unicode Strings.

这是自 Python 2.0 以来的语法.

It's been the syntax since Python 2.0.

Python 3 使它们变得多余,因为默认的字符串类型是 Unicode.3.0 到 3.2 版本删除了它们,但它们在 3.3+ 中重新添加与 Python 2 兼容以帮助实现 2 到 3 的转换.

Python 3 made them redundant, as the default string type is Unicode. Versions 3.0 through 3.2 removed them, but they were re-added in 3.3+ for compatibility with Python 2 to aide the 2 to 3 transition.

这篇关于Python 字符串中的 u 前缀是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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