Fork me on GitHub

随笔分类 -  Ago

内置函数的补充 反射
摘要:# l=list([])# print(type(l)is list)# print(isinstance(l,list))'''True'''# class Foo:# pass# class Bar(Foo):# pass## print(issubclass(Bar,Foo))'''True' 阅读全文
posted @ 2019-12-25 20:14 OBOS 阅读(135) 评论(0) 推荐(0)
绑定方法与非绑定方法
摘要:# import settings# class MySQL:# def __init__(self,host,port):# self.host=host# self.port=port## @classmethod# def from_conf(cls):# return cls(setting 阅读全文
posted @ 2019-12-25 19:02 OBOS 阅读(136) 评论(0) 推荐(0)
封装
摘要:# class Foo:# __N=1# def __init__(self,x,y):# self.x=x# self.__y=y## def __f1(self):# print('f1')## def f2(self):# print(self.__N,self.__y)# print(Foo 阅读全文
posted @ 2019-12-24 16:18 OBOS 阅读(178) 评论(0) 推荐(0)
多态与多态性
摘要:'''多态:同一种事物的多种形态'''# import abc# class Animal(metaclass=abc.ABCMeta):# @abc.abstractmethod# def speak(self):# pass# class Pig(Animal):# def speak(self 阅读全文
posted @ 2019-12-24 09:46 OBOS 阅读(253) 评论(0) 推荐(0)
子类重用父类的功能super
摘要:# class OldboyPeople:# school = 'oldboy'# def __init__(self,name,age,gender):# self.name=name# self.age=age# self.gender=gender# def tell_info(self):# 阅读全文
posted @ 2019-12-23 20:57 OBOS 阅读(182) 评论(0) 推荐(0)
深度优先与广度优先
摘要:# 广度优先# class A(object):# def test(self):# print('from A')# class B(A):# def test(self):# print('from B')# class C(A):# def test(self):# print('from C 阅读全文
posted @ 2019-12-23 20:53 OBOS 阅读(207) 评论(0) 推荐(0)
抽象类
摘要:# class Animal:# def eat(self):# pass# def run(self):# pass## class People(Animal):# def eat(self):# print('people is eating')# def run(self):# print( 阅读全文
posted @ 2019-12-23 16:56 OBOS 阅读(112) 评论(0) 推荐(0)
组合
摘要:# class OldboyPeople:# school = 'oldboy'# def __init__(self,name,age,gender):# self.name=name# self.age=age# self.gender=gender# def tell_info(self):# 阅读全文
posted @ 2019-12-23 12:30 OBOS 阅读(190) 评论(0) 推荐(0)
子类重用父类的功能
摘要:# class Foo:# def f1(self):# print('Foo.f1')# def f2(self):# print('Foo.f2')# self.f1()## class Bar(Foo):# def f1(self):# print('Bar.f1')## obj=Bar()# 阅读全文
posted @ 2019-12-21 20:00 OBOS 阅读(183) 评论(0) 推荐(0)
对象之间的交互
摘要:# class Garen:# camp='demacia'# def __init__(self,nickname,life_value,aggresivity):# self.nickname=nickname# self.life_value=life_value# self.aggrisiv 阅读全文
posted @ 2019-12-19 20:04 OBOS 阅读(179) 评论(0) 推荐(0)
属性查找与绑定方法
摘要:# class Student:# school='oldboy'# def __init__(self,name,age,gender):# self.Name=name# self.Age = age# self.Gender=gender# def learn(self):# print('% 阅读全文
posted @ 2019-12-19 20:03 OBOS 阅读(208) 评论(0) 推荐(0)
类与对象的定义与使用
摘要:'''面向过程与面向对象面向过程:核心是过程二字,过程即解决问题的步骤,就是先干什么再干什么基于该思想写程序就好比在设计一条流水线,是一种机械化的思维方式优点:复杂的过程流程化,进而简单化缺点:扩展性差面向对象:核心是对象二字,对象是特征与技能的结合体基于该思想编写程序就好比在创造一个世界,世界是由 阅读全文
posted @ 2019-12-18 20:33 OBOS 阅读(448) 评论(0) 推荐(0)
hashlib模块subprocess模块
摘要:'''通过一种算法,将字符串得出一种编码内容相同则hash运算结果相同,内容稍微改变则hash值改变不可逆推相同算法,无论校验多长的数据,得到的hash值长度固定'''# import hashlib# m=hashlib.md5()# m.update('hello'.encode('utf-8' 阅读全文
posted @ 2019-12-18 18:30 OBOS 阅读(213) 评论(0) 推荐(0)
configerparser模块
摘要:'''[mysqld]charater-server-set='utf8'default-engine='innodb'skip-grant-table=Trueport=3306[client]user='root'password='123''''# import configparser# c 阅读全文
posted @ 2019-12-17 19:59 OBOS 阅读(331) 评论(0) 推荐(0)
shelve模块 xml模块
摘要:# import shelve# f=shelve.open('db.shl')# # f['stu1']={'name':'alex1','age':28}# # f['stu2']={'name':'alex2','age':18}# print(f['stu1']) # {'name': 'a 阅读全文
posted @ 2019-12-16 20:03 OBOS 阅读(135) 评论(0) 推荐(0)
sys模块 json pickle模块
摘要:# sys模块# import sys# sys.path# sys.argv# sys.exit() # 脚本退出# print('[%s]'%('#'*1))# print('[%s]'%('#'*2))# print('[%s]'%('#'*3))# print('[%s]'%('#'*4)) 阅读全文
posted @ 2019-12-14 19:07 OBOS 阅读(243) 评论(0) 推荐(0)
random模块 os模块
摘要:# random# import random# random.random() # 大于0且小于1之间的小数# random.randint() # 大于等于1且小于等于3之间的整数# random.randrange() # 大于等于1且小于3之间的整数# random.choice([1,'2 阅读全文
posted @ 2019-12-13 20:53 OBOS 阅读(344) 评论(0) 推荐(0)
re模块 时间模块
摘要:# 正则模块'''正则就是用一些具有特殊含义的符号组合到一起用来描述字符或字符串的方法或者说,正则就是用来描述一类事物的规则它内嵌在python中,并通过re模块实现正则表达式模式被编译成一系列的字节码,然后由用c编写的匹配引擎执行''''''生活中处处都是正则比如,描述:四条腿 四条腿的动物或者桌 阅读全文
posted @ 2019-12-12 20:37 OBOS 阅读(254) 评论(0) 推荐(0)
日志模块
摘要:# # 日志模块# # import logging# # logging.debug('debug') # 10 日志级别# # logging.info('info') # 20# # logging.warning('warn') # 30# # logging.error('error') 阅读全文
posted @ 2019-12-11 20:47 OBOS 阅读(93) 评论(0) 推荐(0)
软件开发目录规范
摘要:'''bin 存放一些执行文件,整个程序的入口写在这里 可执行文件 启动文件conf 配置文件lib 库 网上下载的 或者自己写的模块和包core 整个程序的核心逻辑log 日志db 数据库相关的readme 介绍软件怎么使用'''# import sys,os# os.path.abspath(_ 阅读全文
posted @ 2019-12-11 20:45 OBOS 阅读(132) 评论(0) 推荐(0)