With the old Ziko Python data type summary _python

Source: Internet
Author: User
Tags iterable

The following table lists the data types that have been studied, as well as part of the core data types of Python, which are referred to as built-in objects.

Object, is that you face all things are objects, reader to gradually familiar with this name. All data types, is an object. The English word is object, the direct Chinese meaning is the object, this is like us in the reality, the many we see and uses can collectively refer to as "the thing". "Thing" is "object", is an object. In programming, the so-called object-oriented, also can be said to "object-oriented", right? It's easy to be ambiguous.

Object Type examples
Int/float 123, 3.14
Str ' Qiwsir.github.io '
List [1, [2, ' Three '], 4]
Dict {' name ': ' Qiwsir ', ' lang ': ' Python '}
Tuple (1, 2, "three")
Set Set ("Qi"), {"Q", "I"}

Regardless of any type of data, using Dir (object) or Help (obj) allows you to see the relevant functions in interactive mode, which allows you to view the related documentation. Example:

Copy Code code as follows:

>>> dir (dict)

Reader need to move the mouse, you can see the full (the following is essentially a list):

Copy Code code as follows:

[' __class__ ', ' __cmp__ ', ' __contains__ ', ' __delattr__ ', ' __delitem__ ', ' __doc__ ', ' __eq__ ', ' __format__ ', ' __ge__ ', ' __ getattribute__ ', ' __getitem__ ', ' __gt__ ', ' __hash__ ', ' __init__ ', ' __iter__ ', ' __le__ ', ' __len__ ', ' __lt__ ', ' __ne__ ', ' __new__ ', ' __reduce__ ', ' __reduce_ex__ ', ' __repr__ ', ' __setattr__ ', ' __setitem__ ', ' __sizeof__ ', ' __str__ ', ' __ Subclasshook__ ', ' clear ', ' copy ', ' Fromkeys ', ' get ', ' has_key ', ' Items ', ' iteritems ', ' Iterkeys ', ' itervalues ', ' Keys ', ' Pop ', ' Popitem ', ' setdefault ', ' Update ', ' values ', ' viewitems ', ' Viewkeys ', ' viewvalues '

First skip over __ the beginning of the double underline which, look at the back, is the dict built-in function. As for the detailed method of operation, it is obtained by means of similar help (Dict.pop). That's what I said before, say it again, and deepen the impression.

My point of view: learning, the important thing is learning methods, not step-by-step code knocking.

Today, since it is a review, it is necessary to improve on the basis of the original point. So, also want to see above those with double underline the thing that begins, please reader find out, have found this: "__doc". What this is, it is a file that contains a detailed explanation of the objects currently being viewed. You can view this in interactive mode:

>>> dict.__doc__
The display should be like this:

Copy Code code as follows:

"Dict ()-> new empty dictionary\ndict (mapping)-> new dictionary initialized from a mapping object ' s\n (key, value) Pairs\ndict (iterable)-> new dictionary initialized as if via:\n d = {}\n for k, V in iterable:\n d[k] = v\ndict (**kwar GS)-> new dictionary initialized with the name=value pairs\n in the keyword argument list. For Example:dict (one=1, two=2) "

Look at the above mess in English, is there a \ n symbol, what is this? The previous reference to the string is the escape symbol \, which is a different line. In other words, if the above text, according to typesetting requirements, it should be such (of course, in the text, if open, in fact, is the layout of a good version of the appearance).

Copy Code code as follows:

"Dict ()-> New Empty Dictionary
Dict (mapping)-> new dictionary initialized from a mapping object ' s
(key, value) pairs
Dict (iterable)-> new dictionary initialized as if via:
D = {}
For K, v. in iterable:
D[k] = V
Dict (**kwargs)-> new dictionary initialized with the Name=value
In the keyword argument list. For Example:dict (one=1, two=2) "

Perhaps typesetting is still not in line with the willing. However, reader can probably see it. What I'm going to say is not typography, but to tell reader a way to view the meaning of a data type, by Obj.doc file.

Hey, there is actually a way to see the results of typesetting:

Copy Code code as follows:

>>> Print dict.__doc__
Dict ()-> New Empty Dictionary
Dict (mapping)-> new dictionary initialized from a mapping object ' s
(key, value) pairs
Dict (iterable)-> new dictionary initialized as if via:
D = {}
For K, v. in iterable:
D[k] = V
Dict (**kwargs)-> new dictionary initialized with the Name=value
In the keyword argument list. For Example:dict (one=1, two=2)

The above toss about, is to gather space, otherwise this summary of things too little.

All in all, you can get all the help documents in this way, anytime, anywhere. If you can access the Internet, to the official website, is another way.

Do we need to explain anything else? It's all redundant. The only thing that needs to be reader is to be able to order English. But I believe reader can read, I this Shita is inferior to English level, still can make up, not to mention reader?

Summary is not meant to end, is to mean the future. The wonderful is still behind, here is just rest.

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.