Thursday, June 15, 2017

Python常用library

Linux
sudo apt-get install python2.7


SQLAlchemy: python最流行的ORM工具
Logging: http://www.jianshu.com/p/feb86c06c4f4
YAML: http://www.ruanyifeng.com/blog/2016/07/yaml.html

__init__: 双下划线为保留函数
__name: 私有函数/属性

person_1.py:

class Person:

   def __init__(self):
       self.__name = 'haha'#私有属性
       self.age = 22

   def __get_name(self):##私有方法
       return self.__name

   def get_age(self):
       return self.age

person = Person()
print person.get_age()
print person.__get_name()

不带self就是与object无关
def read_tag(file_name, tag, freq_cutoff=-1, init_dict=True):

Dictionary.read_tag(file_name, 'dialogue', freq_cutoff=freq_cutoff)

带self就是与object相关
def add_word(self, word):

dictionary.add_word(token)

继承:
http://www.cnblogs.com/feeland/p/4419121.html



Python语法

No comments:

Post a Comment