Bootstrap

python的binascii模块

binascii用来进行进制和字符串之间的转换

# -*- coding: utf-8 -*-
import binascii

print binascii.b2a_hex('n�  . ���z?W')  # 二进制转十六进制
print binascii.hexlify('n�  . ���z?W')  # 作用同上
print binascii.a2b_hex("6eefbfbd20202e20efbfbdefbfbdefbfbd107a103f15571e")    # 16进制转二进制
print binascii.unhexlify("3132")  # 作用同上

6eefbfbd20202e20efbfbdefbfbdefbfbd107a103f15571e
6eefbfbd20202e20efbfbdefbfbdefbfbd107a103f15571e
n�  . ���z?W
12
 

;