Python class methods

Source: Internet
Author: User

Class A:
Xo= "XO" # static variable
__xo= "FASDFSA"; #私有变量
def __init__ (self,name): #构造方法
Self. Name=name;
def add (self): #普通方法
temp= "%s Output construction parameter"%self. Name
Print (temp)
@staticmethod #定义静态方法 () plus parameters
def stat (name,b):
Print (NAME,B);
@property #类方法
def prer (self):
temp = "%s name"% self. Name
Return Temp
@prer. Setter #给类方法副值
def prer (self,values):
Self. Name=values;
return self. Name
# Get Private variables
def da (self):
return self.__xo;



A=a ("Wang")
Print (A.add ());
A.stat (' W ', 2);
B=a.prer= "2222";
Print (b)
Print (A.da ());

Python class methods

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.