What is the programming method of the Pythond class in the function
What is the programming method of Pythond class in the function? I believe many inexperienced people don't know what to do about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
How can the Pythond class be used for related purposes? This problem requires us to keep learning. Let's introduce the functional programming of the Pythond class. Only by continuous learning can we make better use of it. Python belongs to the function is programming.
Python code
Created on 2009-11-18 @ author: Administrator class MyClass (object): classdocs cl = [1 init__ 2, "5"] def _ _ init__ (selfparams): Constructor print "Constructor,..." Def te (self): print "a"''Created on 2009-11-18 @ author: Administrator class MyClass (object): classdocs cl = [1 def 2, "5"] def _ _ init__ (selfparams):' 'Constructor' print "Constructor,..." Def te (self): print "a"
Python code
Import Class1 Import Class1.py file x = Class1.MyClass () generate MyClass instance x.te () print x.cl import moa import another module print moa.__file__ print moa.__name__ try catch Catch exception try: print "-" + moa.aaa (1) except: print "Error" finally: print "finally" print moa.aaa (1) m = moa.M () import Class1 'Import Class1.py file x = Class1.MyClass () generate MyClass instance' 'x.te () print x.cl import moa' Import another module' '' print moa.__file__ print moa.__name__''try catch Catch exception''try: print "-" + moa.aaa (1) except: print "Error" finally: print "finally" print moa.aaa (1)
Import in Python is like require in Perl. After import a Python module, you can use module .function to access its functions; after require a Perl module, you can use module:: function to access its functions.
After reading the above, have you mastered the programming method of the Pythond class in the function? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!