Type of basic data base 1 python

  1. int plastic
    • For calculating and comparing the digital
    • python3 not long, python2 have plastic surgery and long integer
  2. Binary decimal conversion method
    • bin (10 decimal) == Binary
    • 0b (binary)
    • int ( "binary", 2) == decimal
  3. In shaping the number is not 0 is boolean value will be true
  4. Boolean value, True to 1 (int) Fslse is 0 (int)
  5. As long as the string is not empty Ture, a space is Ture
  6. str (True), str (False) are derived from a string
  7. String
    • python, as long as a quoted string is ''. "." "" "" ""
    • String mainly used for data storage, a small amount of stored data
    • Each letter string or character element is referred to as
    • Index (subscript)
  • From left to right, starting at zero. Find: String name [index] (the brackets [] mean the look similar) A [0] == mA [. 1] == EA [2] == EA [. 3] == T
    - from right to left , starting with -1. Find: String name [index] ** (in brackets [] to find the similar meaning) a = "meet" a [ -1] == ta [-2] == e a- [3] == ea [-4] m ==
    - when index not exceed the maximum index (zero-based) or minimum (from the right at -1)
  • slice
    • a [0: 5], care regardless tail ,, a [starting position: not write (default to the last position)] ,,, a [not write (): Do not write (default to the last position)]
      • a[-5:-1],,,
      • Time is sliced ​​raw data itself
  • Steps
    • Find decided to step direction a [:: step], step size value determines how much each step across, positive or negative decision to seek direction
      • a [start index (0 is not written by default): the end of the table (not included, the default is not written last value): positive step]
      • a [start index (the default is not written -1): at the end of the table (not included, the default is not written to the first value): negative step]
  • String Methods
    • name = "sssd"
    • The number of characters that appear name.count ()
      • name.startswith( , , )
      • name.endswitch(,,)
      • name.upper()
      • name.lower()
      • name.strip () # Default off head and tail sides spaces, carriage returns, tabs. name.strip ( "stripped Content")
      • name.split ( "what division", cut a few (not default write full cut))
      • name.replace (to be for a. change the contents, replace the contents for a few (not default write full replacement))
      • String formatting, name = "{} {} year years old" .format ( "junke", 18)
      • String formatting, name = "{name} {age} year years old" .format ( "name =" junke ", gre = 18)
      • String formatting, name = "{0} 1} {year years old" .format ( "junke", 18), according to the following standard
    • Class is based
      - name.isdigit () string is not judged are whole numbers
      - name.isdecimal () judgment is not = decimal name "123"
      - name.isalnum () judgment is not alphanumeric Chinese
      - name.isalpha ( ) judgment is not a letter Chinese
      - name.isupper ()
      - name.islower ()
      • len (name), find the string length
  1. for loop

    • name= "ekeke" 可迭代对象
      for i in name:
        print(i)
      print(i)
      #输出ekeke    e
      #相当于 i=name[0]...执行到最后,i = a[3] ==e
      
      for i in name:
          pass
      print(i)
      #输出内容  e
      #for循环中pass占位,无内容。但是循环依旧,循环到最后,i=name[3]
      
      
      for i in name:
          i = i+"ke"
      print(i)
      
  2. Iterables

    • In addition to data type int python and the rest can be bool value iteration are iterables

Guess you like

Origin www.cnblogs.com/jingjunke/p/11414743.html