要hex
在Python 3中使用编码,请使用
>>> import codecs
>>> codecs.encode(b"c", "hex")
b'63'
在旧版Python中,还有其他几种方法可以执行此操作:
>>> hex(ord("c"))
'0x63'
>>> format(ord("c"), "x")
'63'
>>> "c".encode("hex")
'63'
如何在python中将单个字符转换为十六进制ascii值
要hex
在Python 3中使用编码,请使用
>>> import codecs
>>> codecs.encode(b"c", "hex")
b'63'
在旧版Python中,还有其他几种方法可以执行此操作:
>>> hex(ord("c"))
'0x63'
>>> format(ord("c"), "x")
'63'
>>> "c".encode("hex")
'63'