摘要: # 面向对象的三大特性# 继承# 多态# 封装# 继承# class ParentClass1: pass# class ParentClass2: pass# # 在python3中 所有的类都继承自object# print(ParentClass1.__bases__)# class Chil 阅读全文
posted @ 2018-03-07 20:54 xuerh 阅读(122) 评论(0) 推荐(0)
摘要: # 面向对象的 讲解 和 组合 # 命名空间# class Person:# Country = '中国人' # 静态变量# print(Person.Country)# alex = Person() # 创建了一个空的命名空间# alex.name = 'alex' # 对象# alex.Cou 阅读全文
posted @ 2018-03-06 18:10 xuerh 阅读(112) 评论(0) 推荐(0)
摘要: # 面向对象 # 引子# 游戏公司 : 人狗大战# 两个角色 类: 人 狗# 人 : 名字 性别 攻击力 生命值hp 描述类# 狗 : 名字 品种 攻击力 生命值# def person(name,sex,aggr,hp): # 人模子# person_dic = {# 'name': name,# 阅读全文
posted @ 2018-03-06 17:30 xuerh 阅读(151) 评论(0) 推荐(0)
摘要: # 模块 = = = == = =#re 模块import re# 使用python操作正则表达式的一个模块# 我们使用这个模块 只需要 自己写正则表达式 和 带匹配的字符# 模块名.方法名()# ret = re.findall('\d', 'eva1 egon2 yuan3') # 返回所有满足 阅读全文
posted @ 2018-03-01 22:45 xuerh 阅读(188) 评论(0) 推荐(0)
摘要: # ######## time 模块import time# 1.time.sleep(secs)# (线程)推迟指定的时间运行。单位为秒。# 2.time.time()# 获取当前时间戳# 在Python中,通常有这三种方式来表示时间:时间戳、元组(struct_time)、格式化的时间字符串:# 阅读全文
posted @ 2018-03-01 22:43 xuerh 阅读(169) 评论(0) 推荐(0)
摘要: # 递归 与 算法#递归# n = 1 金老板 38+2 =40# n = 2 alex n+2= 金老板 36+2 = 38# n = 3 wusir n+2 = alex wusir 36# def age(n): #n = 2# if n == 3:# return 36# else:# re 阅读全文
posted @ 2018-02-26 21:39 xuerh 阅读(192) 评论(0) 推荐(0)
摘要: # 内置函数 #any 判断有一为真 才为真#all 判断 全部为真 才为真# print(any(["",1,0]))#ord 输入字符,返回unicode 对应的编码位置# print(ord("a"))# print(ord("b"))# print(ord("中"))#chr 输入编码位置, 阅读全文
posted @ 2018-02-25 12:56 xuerh 阅读(201) 评论(0) 推荐(0)
摘要: #++ = 列表的推导式# li = []# for i in range(1,11):# li.append(i)# print(li)## lis = [i for i in range(1,11)] #列表的推导式# print(lis)#[变量(加工后的变量) for 变量 i in 可迭代 阅读全文
posted @ 2018-02-07 22:24 xuerh 阅读(261) 评论(0) 推荐(0)
摘要: # set 集合 特点为 无序的 且不重复的 #面试题 = = == = = = = = = = = = = = = 重点# lis = [1,2,1,2,3,4,4,4,3,6,6,7,7,7,2,2,3,3,]# #去重: #1,用算法去做, #2.转换成集合,再转换过来。# set1 = se 阅读全文
posted @ 2018-01-30 20:52 xuerh 阅读(499) 评论(0) 推荐(0)