[Python3 data processing] Data conversion bytes/string/ASCII/GBK...
Article directory
- string str
- character
- byte byte
- hexadecimal
- integer int
- ascii
bytes to integer
0xff 255
Convert hexadecimal string to 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 to bytes
方法1
a=bytes(plotvalue,"gbk")
方法2
a=plotvalue.encode('gbk')