1. Learn how to view Python Help
(1) When we want to see which data type the python variable belongs to, we can use the
Print (Type (varible))
(2) When we want to see what the specific methods of a variable are
varible = Dict (a=1, b=2)
Print (dir (varible))
This shows all the methods of the variable.
(3) After knowing the method, the concrete method will not use what to do?
Help (sorted ())
Or
You can also view usage by pressing Ctrl + left mouse button.
2. Conversion of the Python variable type
As an example,
Age = 100
Print (' My age was ' + age)
Error after execution of the above code
Because age is an integral type (int), it is printed as a string (str) type
Therefore, the type conversion is done before printing:
Age = 100
Print (' My age was ' + str (age))
So the output is normal.
the int () str () dict () list () tuple () is generally a conversion of these types
A = [1, 2, 3, 4, 5]
Print (dir (a)) View method
This article is from the "Note space" blog, so be sure to keep this source http://286577399.blog.51cto.com/10467610/1975821
. Python Help