每天CookBook之Python-102

  • 十六进制的编码和解码
s = b'hello'

import binascii

h = binascii.b2a_hex(s)

print(h)

print(binascii.a2b_hex(h))

import base64

h = base64.b16encode(s)

print(h)

print(base64.b16decode(h))
b'68656c6c6f'
b'hello'
b'68656C6C6F'
b'hello'
posted @ 2016-07-29 21:43  4Thing  阅读(77)  评论(0编辑  收藏  举报