摘要: #格式: 设置颜色开始 :\033[显示方式;前景色;背景色m #说明: 前景色 背景色 颜色 --------------------------------------- 30 40 黑色 31 41 红色 32 ... 阅读全文
posted @ 2019-02-08 15:05 烟云过眼 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 1,封装 # class Room:# def __init__(self,name,length,width):# self.__name = name# self.__length = length# self.__width = width# def get_name(self):# retu 阅读全文
posted @ 2019-02-08 08:47 烟云过眼 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 1,继承 # class A(object):pass # 父类,基类,超类# class B:pass # 父类,基类,超类# class A_son(A,B):pass # 子类,派生类。A_son有2个父类,多继承# class AB_son(A):pass # 子类,派生类# 一个类 可以被 阅读全文
posted @ 2019-02-08 08:46 烟云过眼 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 1,接口类,规范子类的调用接口 # java : 面向对象编程# 设计模式 —— 接口# 接口类 : python原生不支持# 抽象类 : python原生支持的 from abc import abstractmethod,ABCMetaclass Payment(metaclass=ABCMet 阅读全文
posted @ 2019-02-08 08:46 烟云过眼 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 1,# 人狗大战def Dog(name,blood,aggr,kind): dog = { 'name': name, 'blood': blood, # 血量 'aggr': aggr, # 攻击力 'kind': kind, } def bite(person): person['blood' 阅读全文
posted @ 2019-01-23 09:18 烟云过眼 阅读(99) 评论(0) 推荐(0) 编辑
摘要: 1, # 把解决一类问题的模块放在同一个文件夹里 —— 包 # import os# os.makedirs('glance/api')# os.makedirs('glance/cmd')# os.makedirs('glance/db')# l = []# l.append(open('glan 阅读全文
posted @ 2019-01-16 20:34 烟云过眼 阅读(159) 评论(0) 推荐(0) 编辑
摘要: # 序列化 —— 内存中数据转向一个字符串数据类型,以便于进行存储或网络传输# 序列 —— 字符串 # 从数据类型 --> 字符串的过程 序列化# 从字符串 --> 数据类型的过程 反序列化 序列化的模块: # json # 数字 字符串 列表 字典 元组# 通用的序列化格式# 只有很少的一部分数据 阅读全文
posted @ 2019-01-11 10:55 烟云过眼 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 1, #列表、元祖#字典#集合、frozenset#字符串#堆栈 : 先进后出#队列 :先进先出 FIFO # from collections import namedtuple# Point = namedtuple('point',['x','y','z'])# p1 = Point(1,2, 阅读全文
posted @ 2019-01-08 11:20 烟云过眼 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 1, #递归函数 # 了解什么是递归 : 在函数中调用自身函数 # 最大递归深度默认是997/998 —— 是python从内存角度出发做得限制 #RecursionError: maximum recursion depth exceeded while calling a Python obje 阅读全文
posted @ 2018-12-28 22:26 烟云过眼 阅读(378) 评论(0) 推荐(0) 编辑
摘要: 1, # 变量# print(callable(print))# a = 1# print(callable(a))# print(callable(globals))# def func():pass# print(callable(func)) import time# t = __import 阅读全文
posted @ 2018-12-24 20:54 烟云过眼 阅读(101) 评论(0) 推荐(0) 编辑