示例: #!/usr/bin/env python #encoding: utf-8 import binascii fh = open(r'C:\Temp\img\2012517165556.png', 'rb') a = fh.read() #print 'raw: ',`a`,type(a) hexstr = binascii.b2a_hex(a)print aprint hexstr #示意结果为4d5a900003000000.... 本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/bonelee/p/8267727.html ,如需转载请自行联系原作者