python basis of plastic

Int integer python3 definitions used, there is not long

Plastic Magic

String to plastic surgery

E.g

a = '123'

b = int(a)


print(type(b))

<class 'int'>

  

Several digital occupies minimal binary form

E.g

6 = A 

B = a.bit_length ()   

Print (B) # 6 binary representation 110 occupying three positions 

3

 

The other binary to decimal

E.g

= A 'A' 

S = '1110' 

B = int (A, base = 16) # specified variable is represented by a 16 base-band 

D = int (S, base = 2) 

Print (B) 

Print (D) 

10
14

  

Guess you like

Origin www.cnblogs.com/602681352jys/p/11407199.html