字符串

Python3的版本中,字符串的编码是Unicode,他支持多种语言。例如

   >>>print(“我的偶像是Kobe”)

   我的偶像是Kobe

对于单个字符的编码,Python提供了ord()函数获取字符的整数表示,chr()函数把编码转换为对应的字符:

>>> ord('A')
65
>>> ord('中')
20013
>>> chr(66)
'B'
>>> chr(25991)
'文'

常见的用户格式:
%d 整数
%f 浮点数
%s 字符串
%x 十六进制整数
原文地址:https://www.cnblogs.com/bang325/p/7070288.html