2010年2月1日 星期一

python 的 Class 寫法

class chello:
def show(self):
return "hello world class!"

a = chello();
print a.show();

or

class chello:
@property
def show(self):
return "hello world class!"

a = chello()
print a.show

or

#!/usr/bin/python
class chello:
def show(self):
return "hello world class!"

x = chello();
print x.show();

or

class chello:
@classmethod
def show(self):
return "hello class world123!"

a = chello()
print a.show()

沒有留言: