len(x):返回字符串x的长度

如:len("12,四五。i"),输出结果7

 

str(x):返回x的字符串形式  

如:str(1.23),输出结果“1.23”

注:与 eval(x)函数对应功能恰反

 

hex(x)、oct(x):将整数x转化成十六进制、八进制小写形式字符串

如:hex(425)输出结果'0x1a9',oct(425)输出结果'0o651'

 

 

Unicode:python字符串的编码方式。

chr(u),u为整数,Unicode编码,可显示对应的Unicode字符

小例子:Unicode编码的十二星座符号显示

 

for i in range(12):
    print(chr(9800 + i), end=" ")

输出结果:

 

 

D:\pytest\venv\Scripts\python.exe D:/pytest/SongTian/test.py
♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ ♐ ♑ ♒ ♓ 
Process finished with exit code 0

 

posted on 2021-08-08 01:03  讲道理好嘛  阅读(72)  评论(0编辑  收藏  举报