Python sequence, Dictionary memo, and python dictionary memo

Source: Internet
Author: User

Python sequence, Dictionary memo, and python dictionary memo

Python memo:

Sequence: List, string, and tuples
Len (d), d [id], del d [id], data in d
Function:
Cmp (x, y ),
Len (seq ),
List (seq) creates a list based on strings,
Max (args ),
Min (args ),
Reversed (seq ),
Sorted (seq ),
Tuple (seq)
List Method:
Add an object at the end of append,
Count () object count,
Add a list at the end of extend,
Index () the location of the First Matching object,
Insert () inserts an object, pop () removes an object,
The default value is the end. remove () removes the first matched object,
Reverse storage of reverse,
Sort () List sorting does not return,
Sorted () returns the sorting list, but this list remains unchanged.

Tuples: The tuples cannot be modified.
The tuple () parameter is a sequence or tuples that return tuples.

String: All strings are unchangeable.
Find () method, query string, no-1 is returned, and a cursor is returned
Join () method, add element, return the string of the added element
Lower () method, returns the lower-case version of the string
The replace () method returns the string that matches the string after replacement.
Split () method, string segmentation into sequences, inverse join method


Dictionary:
Len (d), d [id], del d [id], data in d
Method:
Copy () to copy the content. If you copy the content directly (a = B), it is actually the copy of the address, pointing to the same address.
Fromkeys ([], []) uses the specified key value to initialize the dictionary. Parameter 1 is the sequence of key values, and parameter 2 is the initial value. The default value is none.
The get (key) method to access the dictionary. No error will be reported if no member is needed,
Has_key () is equivalent to key in d
Items () returns all dictionaries to the list
Keys () returns all the keys as a list
Pop () removes the key-value corresponding to the key value
Popitem () returns a random item removed
Setdefault (key, data) has the same get (), and no random key value can be set
Z. update (y) Updates another dictionary using one dictionary and updates z using y
Values () returns the value in the dictionary in the form of a list

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.