Python commonly used methods are generally built-in functions, or inherited from the method of object, is said to be a tool class method, but I sometimes encounter some problems, some methods can be like a tool to view certain information, more useful, so I summed up some methods, on behalf of my own views, Interested friends to see-see, together with the exchange, the new discoveries will be written here.
1,id () View the memory address of an object, typically used to analyze two objects is not a thing '
A=[1,2,3,4]b={"a": +, "B": 2}print (ID (a)) print (ID (b))
2,dir () View parameters ' properties and Executable methods
Class Foo (): a=100 def __init__ (self,name,age): self.name=name self.age=age def fun01 (self): Pass def fun02 (self): passobj=foo ("Zhangsan") Print (dir (Foo)) print (dir (obj))
3,type () View the data type of an object
A=[1,2,3,4]b={"a": "B": 2}c= "ssdkd" Print (Type (a)) print (type (b)) print (type (c))
4,sys.path () When importing the module to see if a module can be imported, if the module can be imported in all of the output of the road, or to manually add the path
5, class. __mro__ to see the inheritance of a classic class, the default is to follow the C3 algorithm, the general eye can be seen, no eggs, but particularly complex inheritance will not be able to do, you have to use it
Class A (): passclass B (a): passclass C (B): passclass D (C): passprint (d.__mro__)
Python--Tool class method