The second development [python] python basic data types

Basic data types

  • digital 

  1, useless printing up double quotes, supports + - * /% (wherein the fourth power,% ** 4 4 modulo power multiplier 4, i.e. take the remainder, / division, the result is the quotient //)

  2, in python3, no matter how much numbers are of type int

  3, the string is converted to a digital

Conversion and viewing digital type conversion type
a = "123"
print(type(a),a)

b = int(a)
print(type(b),b)

Default without base, int 10 is converted into a binary, plus Base = 16 is converted into a hexadecimal num decimal.
num = "a"
v = int(num,base=16)
print(v)

This figure is expressed in binary with several
age = 4
r = age.bit_length()
print(r)
  • String

     (Quotation marks printed up), support the addition (character stitching), multiplication, str  

      10 substantially magic string (join, split, find, strip, upper, lower, len, replace, for loop, index, slices)

     

     

Guess you like

Origin www.cnblogs.com/wangjingjing-blog/p/11671450.html