function Description 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]) Create a complex number str (x) to convert an object x to a string repr (x) to convert an object x to an expression string eval (str) to evaluate a valid Python expression in a string and return an object tuple (s) Converts a sequence s to a tuple list (s) converts a sequence s to a list Chr (x) converts an integer to a 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 formatted (string only) S[i] index S[I:J] slice x in S, X is in s< c6/> dependency for X in S: iteration len (s) length min (s) min element max (s) max element S[i] = x is s[i] re-assignment s[i:j] = R re- assigns list fragment Value del s[i] Delete an element from the list del s[i:j] delete a fragment from the list
Numeric operation:
X << y left x >> y right shift x & Y bitwise and X | y bitwise or x ^ y bitwise XOR (exclusive OR) ~x bitwise Rollover x + y plus X- Y minus x * y multiply x /y general except X//y floor except × * * * y powers (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 (×, y [, modulo]) return (x * y) x% Modu Loround (x, [n]) rounded, n is the number of decimal places x < Y is less than x > y is greater than x = = y equals x! = y is not equal (same as <>) x >= y
greater than or equal to x <= y is less than or equal