Introduction to python methods and object methods

Source: Internet
Author: User
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!

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.