python 类里面的静态方法

#/usr/bin/env/ python
# _*_ coding:utf-8 _*_
# author:linqinglong
#创建静态方法的用处
class MsSqlHelper:
  @staticmethod
  def add(select):
    pass
  @staticmethod
  def delete(select):
    pass
  @staticmethod
  def update(select):
    pass
  @staticmethod
  def sql(select):
    pass
#需要创建N多个对象, 用静态方法不需要创建N多个对象
ms = MsSqlHelper()
ms.add(select)

MsSqlHelper.add(select)

#创建一个模块,然后写入下面函数,调用模块里的函数与静态方法的区别
#能说明白静态方法是面向对象的思想,与调用module内方法无异
def add(select):

posted @ 2017-01-12 19:23  struggle-fi  阅读(184)  评论(0编辑  收藏  举报