Konvertierung verschiedener Python-Datentypen

[Python3-Datenverarbeitung] Datenkonvertierung Bytes/String/ASCII/GBK ...

Artikelverzeichnis

  • string str
  • Charakter
  • Byte-Byte
  • hexadezimal
  • Ganzzahl int
  • ASCII

Bytes zu Ganzzahl
0xff 255

Konvertieren Sie eine hexadezimale Zeichenfolge in 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 in Bytes

方法1
a=bytes(plotvalue,"gbk")
方法2
a=plotvalue.encode('gbk')

Ich denke du magst

Origin blog.csdn.net/GQ_Sonofgod/article/details/126240758
Empfohlen
Rangfolge