python binary and ASCII conversion Conversion

A, ASCII conversion

Get ascii value of the character

the ord ( " A " ) is acquired // 97

Ascii string value corresponding to the Get

chr (97) // Get the value ' A '

Second, the binary conversion

Decimal turn hex

hex (12) // acquired values: ' 0xc '

Decimal turn octal

oct (10) // acquired values: ' 0o12 '

Binary Decimal turn

bin (174) // acquired values: ' 0b10101110 '

16 hexadecimal string decimal rpm

int ( ' 0xc ' , 16) to obtain a value of 12 //

8 decimal digit string 10 rpm

int ( " 0o12 " ,. 8) is 10 // acquired

Binary string of 10 hexadecimal rotation

int ( ' 0b10101110 ' , 2) // 174 is acquired

10 decimal digit string 10 rpm

int ( " 0010 " ) to obtain a value of 10 //

 

Guess you like

Origin www.cnblogs.com/liyuanhong/p/12167167.html