2021年5月15日

python-*args,**kwargs以及拆包

摘要: def test(a, b, c, *args, **kwargs): print(a) print(b) print(c) print(args) print(kwargs)if __name__ == '__main__': test(1, 2, 3, 44, 55, 66, d=777, e= 阅读全文

posted @ 2021-05-15 22:24 ClarenceSun 阅读(58) 评论(0) 推荐(0) 编辑

python-冒泡排序算法

摘要: def maopao(list): len_list = len(list) for i in range(len_list - 1, 0, -1): count = 0 for j in range(i): if list[j] > list[j + 1]: list[j + 1], list[j 阅读全文

posted @ 2021-05-15 21:05 ClarenceSun 阅读(44) 评论(0) 推荐(0) 编辑

python-队列

摘要: class Quene(): """队列""" def __init__(self): self.__list = [] def enqueue(self,item): """往队列中添加元素""" self.__list.append(item) def dequeue(self): """从队列 阅读全文

posted @ 2021-05-15 16:42 ClarenceSun 阅读(45) 评论(0) 推荐(0) 编辑

2021年5月13日

python-生成器,闭包,装饰器

摘要: 生成器第一种方式:a = (i for i in range(10))next(a)或者for循环取数第二种:函数内有yield,yield相当于两步:1、程序停止,2、return yield后边的值例如:def fib4(): print(" start ") a, b = 0, 1 for i 阅读全文

posted @ 2021-05-13 22:13 ClarenceSun 阅读(37) 评论(0) 推荐(0) 编辑

python-单向链表

摘要: # coding:utf-8class Node(object): def __init__(self, elem): self.elem = elem self.next = Noneclass SingleLinkList(object): def __init__(self, node=Non 阅读全文

posted @ 2021-05-13 20:06 ClarenceSun 阅读(47) 评论(0) 推荐(0) 编辑

python中的列表操作效率

摘要: # coding:utf-8from timeit import Timerdef test1(): li = [] for i in range(10000): li.append(i)def test2(): li = [] for i in range(10000): li = li + [i 阅读全文

posted @ 2021-05-13 20:03 ClarenceSun 阅读(214) 评论(0) 推荐(0) 编辑

python的栈--先进后出,就像杯子

摘要: # coding = utf-8class Stack(object): """栈""" def __init__(self): self.__list = [] def push(self, item): """添加一个元素item到栈顶""" self.__list.append(item) d 阅读全文

posted @ 2021-05-13 19:58 ClarenceSun 阅读(93) 评论(0) 推荐(0) 编辑

2021年4月28日

数据结构与算法的基础知识

摘要: 算法的五大特征输入:0或者多个输入输出:1或者多个输出有穷性:有限的步骤,可接受的时间确定性:每一步都有确定的意义,不会出现二义性可行性:每一步都是可行的 单靠时间判断算法效率不准确,需要结合硬件和环境时间复杂度:T(n) = n^3*2大o表示法:n^3 数据不同,算法执行不同最优时间复杂度最坏时 阅读全文

posted @ 2021-04-28 20:06 ClarenceSun 阅读(150) 评论(0) 推荐(0) 编辑

2021年3月28日

python中的进程和线程

摘要: 进程和线程 多开就是多进程:多个qq多线程就是一个进程多个窗口:多聊天窗口进程是资源分配的单位线程是真正执行代码的队列:先进先出栈:先进后出多进程在python中的作用远远大于多线程,GIL使得每次只有一个线程在占用CPU进程间通信不方便线程通信方便,但是有GIL限制,解决办法:使用C语言来实现线程 阅读全文

posted @ 2021-03-28 22:19 ClarenceSun 阅读(36) 评论(0) 推荐(0) 编辑

2021年3月14日

windows与linux存储文本的区别

摘要: windows与linux存储文本的区别:文本存储和二进制存储区别: windows中文本存储会将换行符\n转换成\r\n进行存储 二进制存储不会进行转换 访问列表元素使用[]和get的区别: []访问时如果不存在会报错 get访问时如果不存在不会报错,而且可以设置默认值 阅读全文

posted @ 2021-03-14 21:02 ClarenceSun 阅读(90) 评论(0) 推荐(0) 编辑

导航