Python-Class Learning

Source: Internet
Author: User

Tag:python    class    

#!/usr/bin/python#coding:utf8class chen ():         name= "Hua Zi is very handsome"         def fun1 (self):      #公有方法可以直接被调用                 print  Self.name                print   "----------------I am the public method"                  self.__fun2 ()         def __fun2 (self):      #私有方法先被本类的公有方法调用 and then external access to the public method                  print self.name                 print  "I am a private method"         @ Classmethod  &nbSp;     def classfun (self):                 print self.name                 print  "I am a class method"           @staticmethod         def staticfun ():                 print chen.name                 print  "I am a static method" # Access to public methods Public=chen () public.fun1 () #类方法的访问chen. Classfun () #静态方法调用chen. Staticfun ()


Python-Class Learning

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.