python string to hex,字符串转16进制

使用python将字符串转换成16进制串:

mystr = ‘1234567’
print ":".join("{:02x}".format(ord(c)) for c in mystr)


得到输出:

'31:32:33:34:35:36:37'


你可能感兴趣的:(python)