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