Python 中的 Unicode 字符串
pythonserver side programmingprogramming更新于 2025/3/31 19:56:17
Python 中的普通字符串在内部存储为 8 位 ASCII,而 Unicode 字符串则存储为 16 位 Unicode。这样可以使用更多样化的字符集,包括世界上大多数语言的特殊字符。我将对 Unicode 字符串的处理限制为以下 −
示例
#!/usr/bin/python print u'Hello, world!'
输出
执行上述代码时,会产生以下结果 −
Hello, world!
如您所见,Unicode 字符串使用前缀 u,就像原始字符串使用前缀 r 一样。
相关文章
有用资源
python 参考教程 - 该教程包含有关 python 的更多信息:https://www.cainiaomax.com/python/

