BINASCII module:
It contains a function that converts a binary value into a 16 binary, which can also be reversed. #binary_value是二进制数值不是字符串, not 1010 of the int type.
Binascii.b2a_hex (binary_value) # #binary_value general read binary file can get >> ' 89 '
Python comes with the BUILTIN function:
Bin (num) decimal value = = = "Binary string"
Bin (Ten) >> ' 0b1010 '
Oct (num) decimal value = = = "Octal string"
Oct (Ten) >> ' 012 '
Hex (num) decimal value = = = "Hex string"
Hex ( >> ' 0x14 ')
Int (str, base) Other binary string = = = "Decimal value, where base represents STR specifically belongs to which binary, if 2 means str is binary, default base is decimal
Int (' 2 ') >>20 int (' 20 ',
8) >>8
int (' + ', ' + ') ' (' + ') ', ' >>2 int ', >>20
int (' + ', +) >>32
Character and number conversion functions:
chr (int) integer-to-character
Chr >> ' A ',
Ord (CHR) character turn-integer
Ord (' a ') >>97,
Finally, give an example of reading a picture file binary content:
#!/usr/bin/env python #encoding: utf-8 import Binascii
1010 Brush screen effect, is not a bit of the hacker Empire Bright Ah, hehe