Python type and built-in functions

Source: Internet
Author: User

List Type Common functions:

Append (obj): Add an object at the end of the list

Count (obj): Count the number of occurrences of an object in a list

Extend (SEQ): Adds the contents of the sequence SEQ to the list

Index (Obj,i=0,j=len): Calculates the index position of the object obj in the list

Insert (Index,obj): Inserts an object into the list at the position specified by index

Pop (INDEX=-1): Reads and deletes an object at the index position, which defaults to the last object

Remove (obj): Removes an object from the list obj

Reverse (): Get reverse List

List.sort (func=none,key=none,reverse=false): Sort members in a list in a specified manner


Set type built-in functions:

Add (): Add new Element

Update (SEQ): The collection is updated with a sequence, and each element of the sequence is added to the collection

Remove (Element): Delete elements

Dictionary (dictionary) built-in functions:

Clear (): Clears all (key, value) pairs in the dictionary.

Copy (): Copy a copy of the dictionary

Fromkeys (Seq,val=none): Creates a dictionary with the elements in SEQ as keys, and all keys are set to val,val default to None

Get (Key,default=none): reads the key in the dictionary, returns the value of the key: Returns the value set by default if the key is not found

Has_key (key): Determines whether the key is present in the dictionary, returns True if it exists, otherwise returns false

Items (): Returns a list that contains the tuple (key, value) in the dictionary

Keys (): Returns a list of all keys in a dictionary

Iteritems (): Returns an iterator to all (key, value) pairs in the dictionary

Iterkeys (): Returns an iterator to all keys in the dictionary

Itervallues (): Returns an iterator to all values in the dictionary

Pop (Key[,default]): Reads the value of a key and removes the value of the key from the dictionary, and throws a Keyerror exception if key key does not exist and default is not set

SetDefault (Key,default=none): Sets the value of key in dictionary to default

Update (DICT): Merging dictionaries

VALUES (): Returns a list that contains all the values in the dictionary

Python type and 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.