摘自python的文档
Boolean Operations — and, or, notOperation Result x or y if x is false, then y, else x x and y if x is false, then x, else y not x if x is false, then True, else False ComparisonsOperation Meaning< strictly less than<= less than or equal> strictly greater than>= greater than or equal== equal!= not equalis object identityis not negated object identityNumeric TypesOperation Result x + y sum of x and y x - y difference of x and y x * y product of x and y x / y quotient of x and y x // yfloored quotient of x and yx % y remainder of x / y -x x negated +x x unchanged abs(x) absolute value or magnitude of x int(x)x converted to integer float(x) x converted to floating point complex(re, im) a complex number with real part re, imaginary part im. im defaults to zero. c.conjugate() conjugate of the complex number c divmod(x, y) the pair (x // y, x % y) pow(x, y) x to the power y x ** y x to the power y Bit-string Operations on Integer TypesOperation Result x | y bitwise or of x and yx ^ y bitwise exclusive or of x and yx & y bitwise and of x and yx << nx shifted left by n bits x >> nx shifted right by n bits ~x the bits of x invertedSequence Types — str, bytes, bytearray, list, tuple, rangeOperation Result x in s True if an item of s is equal to x, else False x not in s False if an item of s is equal to x, else True s + t the concatenation of s and t s * n, n * s n shallow copies of s concatenated s i‘th item of s, origin 0 s slice of s from i to j s slice of s from i to j with step k len(s) length of smin(s) smallest item of smax(s) largest item of sOld String Formatting OperationsConversion Meaning 'd' Signed integer decimal.'i' Signed integer decimal.'o' Signed octal value. 'u' Obselete type – it is identical to 'd'. 'x' Signed hexadecimal (lowercase). 'X' Signed hexadecimal (uppercase). 'e' Floating point exponential format (lowercase). 'E' Floating point exponential format (uppercase). 'f' Floating point decimal format. 'F' Floating point decimal format. 'g' Floating point format. Uses lowercase exponential format if exponent is less than -4 or not less than precision, decimal format otherwise. 'G' Floating point format. Uses uppercase exponential format if exponent is less than -4 or not less than precision, decimal format otherwise. 'c' Single character (accepts integer or single character string).'r' String (converts any python object using repr()). 's' String (converts any python object using str()).'%' No argument is converted, results in a '%' character in the result.Mutable Sequence TypesOperation Result Notess = x item i of s is replaced by xs = t slice of s from i to j is replaced by the contents of the iterable tdel s same as s = []s = t the elements of s are replaced by those of t del s removes the elements of s from the lists.append(x) same as s = s.extend(x) same as s = x s.count(x) return number of i‘s for which s == xs.index(x[, i[, j]]) return smallest k such that s == x and i <= k < j s.insert(i, x) same as s = s.pop() same as x = s; del s; return x s.remove(x) same as del s s.reverse() reverses the items of s in place s.sort(]) sort the items of s in place
页:
[1]