Learning python six (operator)

Operator (operator)
  operator can computes various operations or a value or values
  such as +, -, *, / operators belonging
  operator classification:
    1. arithmetic operators (addition, subtraction)
      + addition operator (if it is an addition operation between two strings, the string operation is performed fight)
      - subtraction operator
      * multiplication operator
      / division operator
      // divisible only saves integer bits in the art
      ** exponentiation , find the value of a power of a few
      remainders modulo%, average of two numbers divided by
    2. the assignment operator
      variable assignment operator can be given the value to the right of the equal sign on the left side of the equal sign
        + = a + = 5 A + =. 5 corresponds to the A
        - A = - =. 5 corresponds to A = A -. 5
        * = * =. 5 corresponds to A = A *. 5 A
           ** A ** = = =. 5 corresponds to the A **. 5 A
        / = a / = 5 corresponds to A = A /. 5
        // // A = =. 5 corresponds to a = a // 5

  3. Comparison operators (relational operators)
    relational operators are used to compare the relationship between the two values, always returns a Boolean value
    if the relationship was established, the return True, otherwise return False
      >> - <<= == =!
      can be greater than two strings in python (equal) or less than (equal to) is performed
      when the string comparison, the comparison is actually encoded Unicode strings (UTF-8)
      If you do not want to compare two Unicode encoding strings, it needs to be converted to digital and then in the comparison

  4. Logical Operators
    Logical Operators mainly used for some logic determines
      not logical negation
        not may be made to the right of the symbol values of the non-operation
        for Boolean NOT operation will be negated operation
        for non-Boolean NOT operation will first convert it to a Boolean value, and then negated
      and logic
        and can operate on both sides of the symbol values
        and the calculation is to find the False, False if the first value, the second value is not watching
        True and print ( "I guess you do not come out!") # The first is True, we will look at the second value, all outputs

        False and print ( "I guess you do not come out!") # The first is False, will not see the second value, not all outputs

      or logic or
        or can operate on both sides of the symbolic value
        or value as long as the two operations there True, returns True
        or operation is to find True, if the first value is True, not to see a second value
        False or print ( "I guess you do not come out!") # the first value is not True, the will output

        True or print ( "I guess you do not come out!") # The first value is True, it will not output

        the operation or non-Boolean values
        when we or the operation of the non-Boolean value, python as it will Boolean value calculation, the original value of the final return

  The conditional operator (ternary operator)
      Syntax: 1 if the statement of the conditional expression 2 else statement
      execution process:
        conditional operator, when executed, will first conditional expressions are evaluated determination
          If the determination result is True, the execution 1 statement, and returns the execution result
          if the determination result is False, the statement 2 is executed, and returns the execution result of
  operator precedence
    and numerals as in the python operation has priority, such as first multiplication and division, after subtraction

Guess you like

Origin www.cnblogs.com/wangwen022/p/11269653.html