Python some important built-in functions

Source: Internet
Author: User
Tags chr instance method iterable

Function

Describe

Abs (number)

Returns the absolute value of a number

Apply (Function[,args[,kwds]])

Invokes the given function, optionally providing a parameter

All (iterable)

Returns trueif all iterable elements are true , otherwise False

Any (iterable)

Returns trueif any of the iterable elements are true , otherwise False

Basestring ()

Str and Unicode abstract superclass for type checking

BOOL (object)

Returns True or False, depending on The boolean value of Object

Callable (object)

Checks whether an object can be called

Chr (number)

Returns the ASCII code for a given number of characters

Classmethod (func)

Method of creating a class from an instance method

CMP (x, y)

Compare x and y- Returns a negative number if x<y ;

Returns a positive number if x>y, or 0 if x=y

Complex (Real[,imag])

Returns the complex number of a given real part (as well as an optional imaginary part)

Dalattr (object, name)

Removes the given property from the given object

Dict ([mapping-or-sequence])

Constructs a dictionary that can optionally be constructed from a map or a list of (key, value) pairs. You can also use the keyword parameter to call

Dir ([Object])

A list of (most) names that are currently visible to the domain, or selectively list (most) attributes of a given object

Divmod (A, B)

Return (a//b, a%b) (float type has special rules)

Enumerate (iterable)

For All item iterations (index, project) in iterable

Eval (string[, Globals[,locals])

Evaluates a string that contains an expression, optionally in a given global scope or local scope

ExecFile (file[, globals[, locals])

Executes a Python file, optionally in a given global scope or local scope

File (filename[,mode[, bufsize])

Creates a file of the given file name, optionally using the given pattern and buffer size

Filter (function, sequence)

Returns a list of elements returned from a function in a given sequence

Float (object)

Convert a string or numeric value to a float type

Frozenset ([iterable])

Creates an immutable collection, which means that it cannot be added to another collection

GetAttr (Object,name[,default])

Returns the value of the attribute specified in the given object, optionally given a default value

Globals ()

Returns the dictionary representing the current scope

Hasattr (object, name)

Checks whether the given object has a specified property

Help ([Object])

Call the built-in Help system, or print help for a given object

Hex (number)

Converts a number to a string in hexadecimal notation

ID (object)

Returns the unique ID of the given object

Input ([prompt])

Equivalent to eval (raw_input (prompt))

Int (object[, radix]

Converts a string or a number (available cardinality) to an integer

Isinstance (object, ClassInfo)

Checks whether the given object is an instance of the given classinfo value,classinfo can be a class object, Tuple of type Object or Class object and type Object

Issubclass (Class1, Class2)

Check if Class1 is a subclass of Class2 (each class is its own subclass)

ITER (object[, Sentine])

Returns an Iterator object, which can be a object_iter () iterator for the iteration sequence (if object supports the _getitem_ method) , or provide a Sentinel, the iterator invokes Object in each iteration until it returns to Sentinel

Len (object)

Returns the length of the given object (number of items)

List ([sequence])

Constructs a list, optionally using the same items as the provided sequence sequence

Locals ()

Returns the dictionary that represents the current local scope (do not modify the dictionary)

Long (object[, Radix])

Converts a string (optionally using a given cardinality radix) or a number to a long integer

Map (function, sequence,...)

Creates a list of values that are returned by the given function functions applied to the provided list sequence each item

Max (Object1, [Object2,...])

If the object1 is a non-empty sequence, the largest element is returned. Otherwise, the supplied parameters (Object1, object2 ...) are returned. the maximum value

Min (Object1, [Object2, ...])

If the object1 is a non-empty sequence, the smallest element is returned. Otherwise, the supplied parameters (Object1, object2 ...) are returned. the minimum value

Object ()

Returns an instance of the base object for all new real classes

Oct (number)

Converts an integer to a string in octal notation

Open (Filename[,mode[,bufsize]])

File alias (use open instead of file when opening files )

Ord (char)

Returns the ascill value of the order character (a character with a length of 1 or a Unicode string)

Pow (x, y[,z])

Returns the y -side of X , optionally modulo z

Property (fget[, fset,[fdel[, Doc]])

returns a range of values (in list form) with the given starting value (including the starting value, default 0) and the end value (not included) and the step (default = 1)

Range ([Start,] stop[step])

Creating properties from a set of accessors

Raw_input ([prompt])

Returns the data entered by the user as a string, optionally using the given prompt prompt

Reduce (function, sequence[, initializer])

Applies the given function to all of the sequences, using the accumulated results as the first parameter, all the items as the second parameter, and optionally the given starting value (initializer)

Reload (module)

Reload into an already loaded module and return it

Repr (object)

Returns a String representing an object, typically used as an eval parameter

Reversed (Sequence)

Returns a reverse iterator to a sequence

Round (float[, N])

Rounds a given floating point, leaving N bits after the decimal point (default = 0)

Set ([iterable])

Returns the collection of elements generated from iterable ( if given )

SetAttr (object, name, value)

Sets the value of the specified property of the given object to the given value

Sorted (iterable[, Cmp][,key][,reverse])

Returns a new sorted list from the Iterable project. Optional parameters and List methods the same parameters in sort

Staticmethod (func)

To create a static (Class) method from an instance method

Str (object)

Returns a well-formatted string representing the object of the given objects

Sum (seq[, start])

Returns a series of numbers added to the optional parameter Start(default = 0) and

Super (type[, Obj/type])

Returns a superclass of the given type (optional as an actual class)

Tuple ([sequence])

Constructs a tuple, optionally using the same items as the supplied sequence sequence

Type (object)

Returns the type of the given object

Type (name, bases, Dict)

Returns a new type object using the given name, base class, and scope

UNICHR (number)

the Unicode version of CHR

Unicode (object[, encoding[, errors])

Returns the Unicode encoded version of the given object , given the encoding and the mode of handling the error (' strict ', ' replace ' or ' ignore ', ' strict ' is the default mode)

VAR ([object])

Returns a dictionary that represents local work, or a dictionary of the attributes of a given object (do not modify the returned dictionary because the modified result is not defined by a language reference)

Xrange ([start,]stop[, Step])

Similar to range, But the returned object uses less memory and is used only for iterations

Zip (Sequence1,...)

Returns a list of tuples, each of which includes an item of a given sequence. The length of the returned list is the same as the shortest length of the supplied sequence

Python some important built-in functions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.