Day7--python's Help

Source: Internet
Author: User

When we want to see what data type a python variable belongs to, we can use print (type variable) when we want to see how a variable is specific, which can be used: variable = dict (a=1,b=2) Print (dir ( variable) so that you can show all the methods of the variable, just to be familiar with a few words, you probably know their common methods, if the specific method will not use what to do?    You can view a sample of its help: M = dict (a=1,b=2) Assist (M.get) results as follows: Get (...)  D.get (K[,d]), D[k] if k in D, else D. D defaults to None. Dir () Number: View attribute syntax: Help ([object]) Parameter description: Object--objects; Return value returns the object helper information. Help (): The function is used to view a detailed description of the function or module's purpose.

Example: Help (sorted) sorted (...) Sorted (iterable, Cmp=none, Key=none, Reverse=false)--The new sorted list can also CTRL + Mouse Zuojian See how the source code is written: Age = 20print (' My Age is: ' +age ' #age是一个整型, print prints This is a string type that needs to be preceded by age in Str. If the report type is not the same, you need to use type () to see the type first, if you do not meet the criteria, you need to convert #int () str () dict () list () tuple () a = [1,2,3,4]print (dir (a)) #查看a有哪些属性

Day7--python's Help

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.