摘要: 阅读全文
posted @ 2020-08-12 17:22 Python代 阅读(200) 评论(0) 推荐(0) 编辑
摘要: # import re## ret = re.match("wwo","two")# if ret:# print(ret.group())# else:# print("匹配失败") """. 匹配任意1个字符(除了\n)[ ] 匹配[ ]中列举的字符\d 匹配数字,即0-9\D 匹配非数字,即不 阅读全文
posted @ 2020-08-12 15:53 Python代 阅读(64) 评论(0) 推荐(0) 编辑
摘要: #! /usr/bin/env python # -*- coding: utf-8 -*- def quick(list): if len(list) < 2: return list tmp = list[0] # 临时变量 可以取随机值 left = [x for x in list[1:] 阅读全文
posted @ 2020-08-12 08:15 Python代 阅读(77) 评论(0) 推荐(0) 编辑
摘要: 原理:拿自己与上面一个比较,如果上面一个比自己小就将自己和上面一个调换位置,依次再与上面一个比较,第一轮结束后最上面那个一定是最大的数 #! /usr/bin/env pythonf # -*- coding: utf-8 -*- def bubble_sort(li): for i in rang 阅读全文
posted @ 2020-08-12 08:14 Python代 阅读(55) 评论(0) 推荐(0) 编辑
摘要: l = list(range(1,101)) def bin_search(data_set,val): low = 0 high = len(data_set) - 1 while low <= high: mid = (low+high)//2 if data_set[mid] == val: 阅读全文
posted @ 2020-08-12 08:13 Python代 阅读(45) 评论(0) 推荐(0) 编辑
摘要: def fun(i): if i == 0: return 0 elif i == 1: return 1 else: return fun(i-2) + fei(i-1) if __name__ == '__main__': for i in range(10): print(fun(i),end 阅读全文
posted @ 2020-08-12 08:12 Python代 阅读(56) 评论(0) 推荐(0) 编辑