Octopress 部落格

一個靜態網站的部落格框架

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()