【Python3数据处理】数据转换 bytes/string/ASCII/GBK…
文章目录
- 字符串str
- 字符
- 字节byte
- 十六进制hex
- 整数int
- ascii
bytes转整数
0xff 255
16进制字符串转为int
ord()
int(hex(12), 16) # 12
int('FF', 16) # 255
int('FFEF', 16) # 65519
a=plotvalue.encode('gbk')
print(type(a))
tmp = int(a.hex(),16)
str转bytes
方法1
a=bytes(plotvalue,"gbk")
方法2
a=plotvalue.encode('gbk')