This article will focus on learning python methods and object methods from a simple example, if you are interested, you can refer to this article to learn python methods and object methods from a simple example. if you are interested, you can refer
This article provides an example of studying the class and object methods of python. The details are as follows:
Class Test_Demo: TEST = 'Test _ value' def _ init _ (self, name, age): self. name = name self. age = age # static method @ staticmethod def test_static (): return Test_Demo.TEST # feature @ property def test_property (self): return self. name + ':' + str (self. age) # class method @ classmethod def test_class (self): return self. TESTif _ name _ = '_ main _': test_demo = Test_Demo ('zj', 23) # print (test_demo.name) print (Test_Demo.test_static ()) print (test_demo.test_property) print (test_demo.test_class ())
Output result:
Is the above all the content in this article, and I hope it will help you in your learning.
For more articles about python and object methods, refer to PHP!