摘要: lambda相当于def定义函数 一一对应 阅读全文
posted @ 2016-12-29 10:16 灬歧途 阅读(138) 评论(0) 推荐(0) 编辑
摘要: def a4(arg): ret = {} for key,value in arg.items(): if len(value) > 2: ret[key] = value[0:2] else: ret[key] = value return ret dic = {"k1": "v1v1... 阅读全文
posted @ 2016-12-28 17:46 灬歧途 阅读(7088) 评论(1) 推荐(0) 编辑
摘要: def a3(arg): ret = [ ] for i in range(len(arg)): if i % 2 == 1: ret.append(arg[i]) else: pass return ret li = [11,22,33,44,55] r = a3(li) print(li)... 阅读全文
posted @ 2016-12-28 16:38 灬歧途 阅读(5686) 评论(1) 推荐(0) 编辑
摘要: def a2(arg): if len(arg) > 2: del arg[2:] li = [12,13,14,15] a2(li) print(li) 阅读全文
posted @ 2016-12-28 15:42 灬歧途 阅读(6213) 评论(1) 推荐(0) 编辑
摘要: def shifou_space(args): ret = True for a in args: if a.isspace(): ret = False break return ret result = shifou_space("123 12312") print("有空格",result) 阅读全文
posted @ 2016-12-28 15:38 灬歧途 阅读(5319) 评论(2) 推荐(0) 编辑
摘要: def obj_len(arg): #isinstance(),判断是否是某一类 if isinstance(arg,str) or (isinstance(arg,list)) or (isinstance(arg,tuple)): if len(arg) > 5: return True else: ... 阅读全文
posted @ 2016-12-28 13:14 灬歧途 阅读(396) 评论(0) 推荐(0) 编辑
摘要: def func1(s): al_num = 0 spance_num = 0 digit_num = 0 others_num = 0 for i in s: if i.isdigit(): # isdigit 判断有没有数字 digit_num += 1 elif i.isspace(): ... 阅读全文
posted @ 2016-12-28 09:28 灬歧途 阅读(9672) 评论(0) 推荐(0) 编辑
摘要: 声明:本篇笔记,模仿与其它博客中的内容 浅拷贝 浅拷贝,在内存中只额外创建第一层数据 3、深拷贝 深拷贝,在内存中将所有的数据重新创建一份(排除最后一层,即:python内部对字符串和数字的优化) 阅读全文
posted @ 2016-12-27 18:11 灬歧途 阅读(196) 评论(0) 推荐(0) 编辑
摘要: #局部变量,只能调用函数体内的变量 def fun(): a = 234 print(a) #全局变量,在函数体外声明,在函数体内都可调用 b = 'gyc' def fun(): a = 234 print(a,b) # 在局部内修改全局变量 b = 789 def fun(): a = 234 global b ... 阅读全文
posted @ 2016-12-27 17:53 灬歧途 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 第二种动态参数 **a 两个星号,必须有一个key,一个vlue 总结:一个星号,会把所有参数转为tupe,两个星号会把参数转为dict 在接收参数加*,可以吧传入的传入值整体的打印出来 不加* 它只会把值作为一个元素打印出来 阅读全文
posted @ 2016-12-27 11:11 灬歧途 阅读(3738) 评论(1) 推荐(1) 编辑