11 2018 档案

摘要:def __init__(self,name): self.name = name self.courses = [] self.flag = False with open('students','rb') as f1,open('students.bak','wb') as f2: ... 阅读全文
posted @ 2018-11-28 17:54 张朝华 阅读(197) 评论(0) 推荐(0) 编辑
摘要:也就是说_replace方法并不是改变point里的x,而是新建了一个p,这个新建的p中的x=3,所以要改变原来的p还必须加上p=p._replace的这样的赋值语句 阅读全文
posted @ 2018-11-25 15:12 张朝华 阅读(165) 评论(0) 推荐(0) 编辑
摘要:def donot_use_mutable_default_param(idx=0, ids=None): if ids is None: ids = [] ids.append(idx) print(idx) print(ids) donot_use_mutable_default_param(idx=1) donot_use_mutable_d... 阅读全文
posted @ 2018-11-25 11:17 张朝华 阅读(102) 评论(0) 推荐(0) 编辑
摘要:def show(con,col_l,symbol,condition): con_name, con_value = con.split(symbol) # con_name = 'age',con_value = 20 for line_lst in read_file(): num = name_value[con_name] # num = 2 ... 阅读全文
posted @ 2018-11-24 11:28 张朝华 阅读(152) 评论(0) 推荐(0) 编辑
摘要:with open('file/userinfo',encoding='utf-8') as f1,\ # open('file/userinfo.new',mode='a',encoding='utf-8') as f2: 阅读全文
posted @ 2018-11-24 11:21 张朝华 阅读(169) 评论(0) 推荐(0) 编辑
摘要:生成器不调用不运行 列表推导式要值相当于调用生成器推导式,生成器中的值取了就没了 阅读全文
posted @ 2018-11-22 17:24 张朝华 阅读(110) 评论(0) 推荐(0) 编辑
摘要:def search(l,aim,start=0,end=None): if not end:end = len(l)-1 if start mid_value: start = mid+1 ret = search(l,aim,start,end) re... 阅读全文
posted @ 2018-11-22 15:59 张朝华 阅读(153) 评论(0) 推荐(0) 编辑
摘要:[1,2,3] [1,2,10] [1,2,10] 阅读全文
posted @ 2018-11-21 10:08 张朝华 阅读(152) 评论(0) 推荐(0) 编辑
摘要:try: 报错的代码行 except 报错类别 break 阅读全文
posted @ 2018-11-18 14:12 张朝华 阅读(135) 评论(0) 推荐(0) 编辑
摘要:def add(n,i): return n+i def test(): for i in range(4): yield i g=test() for n in [1,10,3]: g=(add(n,i) for i in g) ''' n=1 g=(add(n,i) for i in g) n=2 g=(add(n,i) for i in g) n... 阅读全文
posted @ 2018-11-07 10:08 张朝华 阅读(256) 评论(0) 推荐(0) 编辑
摘要:重点在于新名字的加入用新字典直接暴力添加相同数据然后在加入列表 阅读全文
posted @ 2018-11-01 17:36 张朝华 阅读(298) 评论(0) 推荐(0) 编辑
摘要:p2: 重复代码 语言不统一 不支持中文 input() 输入数字 获取数字 输入字符串必须自己手动写引号 raw_input 和p3中的 input 一样 print可以加括号 也可以不加括号 p2 中除法获取到的是整型如果有一个是浮点数获取到的是小数 range(3,5)输出3,4,5返回的是列 阅读全文
posted @ 2018-11-01 15:36 张朝华 阅读(151) 评论(0) 推荐(0) 编辑