python函数中文手册内容摘要:

bject) Return the “identity” of an object. This is an integer (or long integer) which is guaranteed to be unique and constant for this object during its lifetime. Two objects with nonoverlapping lifetimes may have the same id() value. 如果想知道某个对象的内存地址,用这个内置函数 ,返回的是 10 进制的地址。 33. input([prompt]) Equivalent to eval(raw_input(prompt)). 34. int([x[, base]]) Convert a string or number to a plain integer. If the argument is a string, it must contain a possibly signed decimal number representable as a Python integer, possibly embedded in whitespace. The base parameter gives the base for the conversion (which is 10 by default) and may be any integer in the range [2, 36], or zero. If base is zero, the proper radix is determined based on the contents of string。 the interpretation is the same as for integer literals. (See Numeric literals.) If base is specified and x is not a string, TypeError is raised. Otherwise, the argument may be a plain or long integer or a floating point number. Conversion of floating point numbers to integers truncates (towards zero). If the argument is outside the integer range a long object will be returned instead. If no arguments are given, returns 0. 35. isinstance(object, classinfo) Return true if the object argument is an instance of the classinfo argument, or of a (direct or indirect) subclass thereof. Also return true if classinfo is a type object (newstyle class) and object is an object of that type or of a (direct or indirect) subclass thereof. If object is not a class instance or an object of the given type, the function always returns false. If classinfo is neither a class object nor a type object, it may be a tuple of class or type objects, or may recursively contain other such tuples (other sequence types are not accepted). If classinfo is not a class, type, or tuple of classes, types, and such tuples, a TypeError exception is raised. 36. issubclass(class, classinfo) Return true if class is a subclass (direct or indirect) of classinfo. A class is considered a subclass of itself. classinfo may be a tuple of class objects, in which case every entry in classinfo will be checked. In any other case, a TypeError exception is raised. 37. 导管,窗口,容器, 数据的窗口化 iter(o[, sentinel]) Return an iterator object. The first argument is interpreted very differently depending on the presence of the second argument. Without a second argument, o must be a collection object which supports the iteration protocol (the __iter__() method), or it must support the sequence protocol (the __getitem__() method with integer arguments starting at 0). If it does not support either of those protocols, TypeError is raised. If the second argument, sentinel, is given, then o must be a callable object. The iterator created in this case will call o with no arguments for each call to its next() method。 if the value returned is equal to sentinel, StopIteration will be raised, otherwise the value will be returned. iter(o[, sentinel])返回一个迭代器对象。 第一个参数根据第二个参数进行编译。 第二参数为空, O 必须是支持迭代器的协议 (the __iter__() method)的集合对象 ,或者支持顺序协议 (the __getitem__()method with integer arguments staring at 0).如果不支持其中任意一种协议,程序将会抛出类型异常。 假如第二个参数被给出,然后 O 必须是一个可被调用的对象。 迭代器 被创建万一will 掉用 O with 没有参数 for each call to its next() method。 如果返回值和初始值相同 l, StopIteration 将会抛出 , 否则值会被返回。 (常用函数) len(s) Return the length (the number of items) of an object. The argument may be a sequence (string, tuple or list) or a mapping (dictionary). 用法: list([iterable]) Return a list whose items are the same and in the same order as iterable‘s items. iterable may be either a sequence, a container that supports iteration, or an iterator object. If iterable is already a list, a copy is made and returned, similar to iterable[:]. For instance, list(39。 abc39。 ) returns [39。 a39。 , 39。 b39。 , 39。 c39。 ] and list( (1, 2, 3) ) returns [1, 2, 3]. If no argument is given, returns a new empty list, []. 40. locals() Update and return a dictionary representing the current local symbol table. Free variables are returned by locals() when it is called in function blocks, but not in class blocks. Update and return a dictionary 更新和返回字典 41. long([x[, base]]) Convert a string or number to a long integer. If the argument is a string, it must contain a possibly signed number of arbitrary size, possibly embedded in whitespace. The base argument is interpreted in the same way as for int(), and may only be given when x is a string. Otherwise, the argument may be a plain or long integer or a floating point number, and a long integer with the same value is returned. Conversion of floating point numbers to integers truncates (towards zero). If no arguments are given, returns 0L. 42. map(function, iterable, ...) Apply function to every item of iterable and return a list of the results. If additional iterable arguments are passed, function must take that many arguments and is applied to the items from all itera。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。