an int (string_num, n) string_num represents some kind of binary string, and n is the number of binary numbers that are string_num.
2, 8, 16 binary to 10: using int () or eval ()
10 binary to 2, 8, 16 binary: Using Bin (), Oct (), Hex () or using format ()
B: Binary, O: octal, D: Decimal, x: Hex
Bin (), Oct (), Hex () return values are strings and are prefixed with 0b, 0o, 0x, respectively
The hex function is slower than the Format function, and the Eval function is slower than the INT function
Example:
#Binary goto DecimalPrint(Int ("1111011", 2))Print(Eval ("0b1111011"))#Decimal Turn binaryPrint(Bin (18))Print("{0:b}". Format (18))#Octal goto DecimalPrint(Int ("011", 8))Print(Eval ("0o011"))#Decimal Turn octalPrint(Oct (30))Print("{0:o}". Format (30))#Hexadecimal goto DecimalPrint(Int (" A", 16))Print(Eval ("0x12"))#Decimal Turn hexPrint(Hex (87))Print("{0:x}". Format (87))
Conversion between python--and binary systems