python - binascii-- binary and ASCII encoded binary conversion

Import binascii 
A = B ' worker ' 
# b'worker ' 
B = binascii.b2a_hex (A)   # bin to hex 
# b'776f726b6572' 
C = binascii.a2b_hex (B)   # converted into a binary hexadecimal 
# B 'worker' 

D = binascii.hexlify (A)   # bin to hexadecimal 
E = binascii.unhexlify (B)   # 16 hexadecimal is converted into binary 
# b'worker ' 
Print (A, B, C, D, E)

 

 

 

Guess you like

Origin www.cnblogs.com/liming19680104/p/12175570.html