int (x [, Base]) converts x to an integer
Long (x [, Base]) converts x to a long integer
Float (x) converts x to a floating-point number
Complex (real [, Imag]) creates a complex number
STR (x) converts an object x to a string
REPR (x) converts an object x to an expression string
Eval (str) is used to calculate a valid Python expression in a string and returns an object
Tuple (s) converts a sequence s to a tuple
List (s) converts the sequence s to a list
Chr (x) converts an integer to one character
UNICHR (x) converts an integer to a Unicode character
Ord (x) converts a character to its integer value
Hex (x) converts an integer to a hexadecimal string
Oct (x) converts an integer to an octal string
The sequence supports the following:
Operation description
S + R sequence connection
S * N, n * s S n times copy, n is integer
S% d string formatting (string only)
S[i] Index
S[I:J] Slices
X in S, X isn't in S dependency
For x in S: Iteration
Len (s) length
Min (s) min element
Max (s) max element
S[i] = x is s[i] re-assigned
S[I:J] = R re-assigns the list fragment
Del S[i] Remove an element from the list
Del S[i:j] Delete a fragment from the list
Operation description
S + R sequence connection
S * N, n * s S n times copy, n is integer
S% d string formatting (string only)
S[i] Index
S[I:J] Slices
X in S, X isn't in S dependency
For x in S: Iteration
Len (s) length
Min (s) min element
Max (s) max element
S[i] = x is s[i] re-assigned
S[I:J] = R re-assigns the list fragment
Del S[i] Remove an element from the list
Del S[i:j] Delete a fragment from the list
Numeric operation:
x << y shift left
x >> y Shift Right
X & y Bitwise AND
x | Y bitwise OR
x ^ y bitwise XOR (exclusive OR)
~x rollover by bit
x + y Plus
X-y minus
X * y Multiply
X/y general except
X//Y floor except
X * * y-exponentiation (XY)
X% y modulo (x mod y)
-X Change the symbol bit of the operand
+x do nothing.
~x ~x=-(x+1)
ABS (x) absolute value
Divmod (x, y) return (int (× x/y), x% y)
Pow (x, y [, modulo]) returns (x * * y) x% modulo
Round (x, [n]) rounded, n is the number of decimal places
x < y less than
x > Y greater than
x = = y equals
X! = y Not equal (same as <>)
x >= y is greater than or equal to
X <= y is less than or equal to