标签:add create created john span bsp code 面向对象 核心编程
Python并不强求你以面向对象的方式编程(与Java不同)
# coding=utf8 class FooClass(object): version = 0.1 def __init__(self, nm=‘John Doe‘): self.name = nm print(‘Created a class instance for‘, nm) def showname(self): print(‘Your name is ‘, self.name) print(‘My name is ‘, self.__class__.__name__) def shower(self): print(self.version) def addMe2Me(self, x): return (x + x) foo1 = FooClass() foo1.showname() print(foo1.shower()) print(foo1.addMe2Me(5)) print(foo1.addMe2Me(‘xyz‘)) foo2 = FooClass(‘Jane Smith‘) foo2.showname()
标签:add create created john span bsp code 面向对象 核心编程
原文地址:http://www.cnblogs.com/lqcdsns/p/6038151.html