示例:#!/usr/bin/env python#encoding: utf-8import binasciifh = 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....