摘要: def partition(li, left, right): """ 取出列表最左边的点作为基点, 从列表右边开始遍历列表,如果li[right]>= tmp不成立, 此时li[right] < tmp,将li[right] 赋值给li[left] ,依次循环 """ tmp = li[left] 阅读全文
posted @ 2021-01-18 11:11 traurig 阅读(87) 评论(0) 推荐(0) 编辑
摘要: def insert_sort(li): for i in range(1, len(li)): # 表示摸到的牌的下标 tmp = li[i] j = i - 1 # 指的是手里的牌的下标 while j >= 0 and li[j] > tmp: li[j+1] = li[j] j -= 1 l 阅读全文
posted @ 2021-01-18 01:08 traurig 阅读(44) 评论(0) 推荐(0) 编辑
摘要: def select_sort_simple(li): li_new = [] for i in range(len(li)): min_val = min(li) li_new.append(min_val) li.remove(min_val) return li_new def select_ 阅读全文
posted @ 2021-01-18 00:12 traurig 阅读(36) 评论(0) 推荐(0) 编辑
摘要: def binary_search(li, val): left = 0 right = len(li) - 1 while left <= right: # 候选区有值 mid = (right + left) // 2 if li[mid] == val: return mid elif li[ 阅读全文
posted @ 2021-01-17 12:21 traurig 阅读(89) 评论(0) 推荐(0) 编辑
摘要: def bubble_sort(li): # O(n²) for i in range(len(li) - 1): for j in range(len(li) - i - 1): if li[j] > li[j + 1]: li[j], li[j + 1] = li[j + 1], li[j] # 阅读全文
posted @ 2021-01-17 12:17 traurig 阅读(81) 评论(0) 推荐(0) 编辑
摘要: def linear_search(li, val): # O(n) for ind, v in enumerate(li): if v == val: return ind else: return None 阅读全文
posted @ 2021-01-17 11:48 traurig 阅读(75) 评论(0) 推荐(0) 编辑
摘要: def hanoi(n, a, b, c): """ 汉诺塔问题: 1.将n-1个盘子从a移动到c 2.将a剩下的一个盘子从a移动到c 3,将n-1个盘子从b经过a移动到c """ if n > 0: hanoi(n - 1, a, c, b) print("moving from %s to %s 阅读全文
posted @ 2021-01-17 11:27 traurig 阅读(64) 评论(0) 推荐(0) 编辑
摘要: OperationalError: (2003, "Can't connect to MySQL server on '10.9.30.190' (timed out)") (IP地址为远程连接数据库的地址) 环境为在本地桥接了两台虚拟机,用一台连接另一台报错,测试了ping 命令 ping不通 后 阅读全文
posted @ 2021-01-11 17:42 traurig 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 首先执行下面一条命令 生成 jupyter notebook的配置文件 jupyter notebook --generate-config 进入路径修改配置 绑定ip 修改 ## The IP address the notebook server will listen on. # Defaul 阅读全文
posted @ 2020-12-12 22:23 traurig 阅读(1020) 评论(0) 推荐(0) 编辑
摘要: 第一步 导包 1 import requests 2 from lxml import etree 3 from threading import Thread 4 from queue import Queue 5 import time 6 import redis 7 import re 8 阅读全文
posted @ 2020-07-05 19:22 traurig 阅读(141) 评论(0) 推荐(0) 编辑