Paul C's Blog

To be funny,to grow up!

0%

2to16

1
2
3
4
5
6
7
8
9
10
11
#!/usr/bin/env python
#读取二进制文件,转为16进制输出
#encoding: utf-8
import binascii
#fh = open(r'E:\test.png', 'rb')
#a = fh.read()
#print 'raw: ',`a`,type(a)
a='011001100110110001100001011001110111101101100011011001010011001101100101001101010011000000110010011000110010110100110100001110000110001100111001001011010011010001100100001101010011000000101101001110010011100100111001001100000010110100110101011000100011100000110001011001000110001000110110011001100110001101100010011001100011000001111101'
hexstr = binascii.b2a_hex(a)
print a
print hexstr #示意结果为4d5a900003000000....