摘要: 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) 编辑