入门客AI创业平台(我带你入门,你带我飞行)
博文笔记

python将字符串转成16进制的ASCii码的值

创建时间:2012-01-25 投稿人: 浏览次数:11597


binascii.a2b_hex(hexstr)
binascii.unhexlify(hexstr)
Return the binary data represented by the hexadecimal string hexstr. This function is the inverse of b2a_hex(). hexstr must contain an even number of hexadecimal digits (which can be upper or lower case), otherwise a TypeError is raised.

帮助
1 2 3 4 5 6 7 >>> a= "x00x91xe2xbexf1x00x04xc4x94xbaxf7xa2x11xf7x11fxe4Ax1cxcc­"  >>> import binascii  >>> binascii.b2a_hex(a)  "0091e2bef10004c494baf7a211f71166e4411ccc"  >>> str1 = "fadsfasf" >>> print binascii.b2a_hex(str1) "6661647366617366"

来源:http://www.dreamrunner.org/2011/11/convert-between-binary-and-ascii/



声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
  • 上一篇:没有了
  • 下一篇:没有了
未上传头像