in the python in development, we often use python class, today through the example and we grilled a class of properties, come together to see it.
Class properties
1. class definition is present and does not need to be instantiated
2. class attributes allow different instances of the same class to hold the same variable together
Class attribute Instance
attrb.py
Class Testcss:
CSSA = ' Class-attribe '
def __init__ (self):
SELF.A = 0
SELF.B = 10
def info (self):
Print (' A: ', self.a, ' b: ', self.b, ' Cssa: ', testcss.cssa)
def define_a (self):
SELF.C = 19
if __name__ = = ' __main__ ':
# TC = TESTCSS ()
# Tc.info ()
# tc.color = ' Red '
# Print (tc.color)
# TC = TESTCSS ()
# TCA = Testcss ()
# TC.A = 100
# TC.B = 200
# Tc.info ()
# Tca.info ()
# TC = TESTCSS ()
# tc.define_a ()
# Print (tc.c)
TC = TESTCSS ()
Tc.info ()
TCA = Testcss ()
Tc.info ()
Testcss.cssa = 0
Tc.info ()
Tca.info ()
The running result of the program Is:
Original Link:http://www.maiziedu.com/wiki/python/generic/
Python class properties in a detailed