随笔分类 - Python
摘要:一、时间复杂度 是用来估计算法运行时间的一个式子(单位) 一般来说,时间复杂度高的算法比复杂度低的算法慢 常见的时间复杂度排序(按效率排序)o(1)<o(logn)<o(n)<o(logn)<o(n*n)... 如何一眼判断时间复杂度: a.循环减半的过程 --》 o(logn) ; b.几次循环就
阅读全文
摘要:1、冒泡 def bubble_sort_1(li): for i in range(len(li) - 1): exchange = False for j in range(len(li) - i - 1): if li[j] > li[j+1]: li[j], li[j+1] = li[j+1
阅读全文
摘要: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: return mid elif data_s
阅读全文
摘要:参考:https://www.cnblogs.com/jiangfan95/p/11468721.html 理解:可变不可变是指修改后内存地址是否改变 可变数据类型: Set(集合) List(列表) Dictionary(字典) 不可变数据类型: Number(数字) String(字符串) Tu
阅读全文
摘要:参考: https://www.cnblogs.com/monogem/p/9765199.html
阅读全文
摘要:队列:跟list差不多,只是消费完一个就少一个 1、异步处理 2、保证顺序 import queue import random import threading import time orders_q = queue.Queue()#队列异步处理,保证顺序执行 #生成者 def produce(
阅读全文
摘要:装饰器,不改变原来的函数,给函数添加新功能,可以自己写,也有写好的 1 def timer(func): 2 def war(*args,**kwargs): 3 start= time.time() 4 res = func(*args,**kwargs) 5 end_time = time.ti
阅读全文
摘要:多线程、多进程 进程:一个进程就是一个程序。线程:线程就是进程里面最小的执行单元。线程是在进程里面的,干活的还是线程。一个进程里面最少有一个线程,可以有多个线程每个线程之间都是互相独立的没有真正意义上的并发,你的电脑的cpu是几核的,那么最多只能同时运行几个任务。 串行: 1 import thre
阅读全文
摘要:''' a) 字符串数组的最大前缀 flow flower flop 最长前缀 flo 比如cat dog 最长前缀 空字符串输出 ''' def max_s(li): for k in li: flag_str = li[0][0] if k[0]!=flag_str: print('null')
阅读全文
摘要:requests模块: import requests url = 'http://127.0.0.1:8888/login' data = {"username":"zjr","password":"1"} r = requests.get(url,data) # r = requests.pos
阅读全文
摘要:参考:https://www.cnblogs.com/Mr-Simple001/p/10516148.html (搞定,感谢原博主) 1.instantclient-basic-windows.x64-11.2.0.4.0.zip(64位) --这个必须要安装 地址1: 百度网盘下载地址:https
阅读全文
摘要:写excel--xlwt模块 import xlwt # book = xlwt.Workbook() # sheet = book.add_sheet('students1') # sheet.write(0,0,'id') # sheet.write(0,1,'name') # sheet.wr
阅读全文
摘要:import pymysql host='127.0.0.1' user = 'jxz' password = '123456'#字符串 db = 'jxz' port = 3306#int类型 connect = pymysql.connect(host=host,port=port,db=db,
阅读全文
摘要:l = ['a','b','c','d','e','f'] for i in enumerate(l):#枚举函数 print(i) for index,item in enumerate(l):#枚举函数 print(index,item)#打印索引和值 运行结果:
阅读全文
摘要:import yamail # import yagmail #发附件的附件如果是中文名是乱码 username = 'testing_dhcc@163.com' passwd = 'aaaaaaa'#授权码 # smtp = yamail.SMTP(host='smtp.qq.com', # us
阅读全文
摘要:import os,sys,platform ini="""[global] index-url = https://pypi.doubanio.com/simple/ [install] trusted-host=pypi.doubanio.com """ os_version=platform.
阅读全文
摘要:import os,random,sys,time import string print(random.randint(1,100))#包含100 print(random.uniform(1,10))#小数 print(random.choice(string.ascii_lowercase))
阅读全文
摘要:print(all([1,2,3,4]))#True 都为真才为真 print(all([1,2,3,0]))#False print(all([1,2,3,False]))#False print(any([1,2,3,4]))#True 都为False才为假 print(any([0,0,0,0
阅读全文
摘要:import time #时间戳 一串数字 #从unix元年 #格式化好的时间 2020-08-29 12:08:07 print(time.time())#当前时间戳 print(time.strftime('%Y-%m-%d %H:%M:%S'))#当前格式化好的时间 seven = int(t
阅读全文
摘要:import os print(os.listdir(r'E:\study\scripts\python\TMZ0\day5')) print(os.name)#操作系统 os.mkdir('java')#只可创建一个目录 os.makedirs('python/day1')#可创建多级目录,自动创
阅读全文

浙公网安备 33010602011771号