摘要: dic = { 'sum_size':0, 'file_num':0, 'directory_num':0}def get_size(path,txt): items =os.listdir(path) files = [] dirs = [] sum_size = 0 for item in items: item = os.pat... 阅读全文
posted @ 2018-10-16 14:44 Woowo 阅读(6340) 评论(0) 推荐(0) 编辑
摘要: import rebracket = re.compile(r'\([^()]+\)') # 寻找最内层括号规则mul = re.compile(r'(\d+\.?\d*\*-\d+\.?\d*)|(\d+\.?\d*\*\d+\.?\d*)') # 寻找乘法运算规则div = re.compile(r'(\d+\.?\d*/-\d+\.?\d*)|(\d+\.?\d*/\d+\.?\d*)'... 阅读全文
posted @ 2018-10-16 12:19 Woowo 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 文件a2.txt内容: 文件内容: 序号 部门 人数 平均年龄 备注 1 python 30 26 单身狗 2 Linux 26 30 没对象 3 运营部 20 24 女生多 通过代码,将其构建成这种数据类型: [{'序号':'1','部门':Python,'人数':30,'平均年龄':26,'备注 阅读全文
posted @ 2018-10-03 22:11 Woowo 阅读(139) 评论(0) 推荐(0) 编辑
摘要: i=1 sum=0 while i <100: if i == 88: i += 1 continue if i %2 != 0: # 奇数加 sum = sum+i else: sum = sum-i # 偶数减 i += 1 print(sum) #计算 1 - 2 + 3 - 4 + 5 .... 阅读全文
posted @ 2018-10-03 09:44 Woowo 阅读(327) 评论(0) 推荐(0) 编辑
摘要: 编译器是把源程序的每一条语句都编译成机器语言,并保存成二进制文件,这样运行时计算机可以直接以机器语言来运行此程序,速度很快; 而解释器则是只在执行程序时,才一条一条的解释成机器语言给计算机来执行,所以运行速度是不如编译后的程序运行的快的. 阅读全文
posted @ 2018-10-02 10:25 Woowo 阅读(84) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2018-09-14 11:14 Woowo 阅读(50) 评论(0) 推荐(0) 编辑
摘要: from greenlet import greenlet import time def test1(): while True: print('----A----') g2.switch() time.sleep(0.5) def test2(): while True: print('----B----')... 阅读全文
posted @ 2018-09-13 18:13 Woowo 阅读(111) 评论(0) 推荐(0) 编辑
摘要: def fib(num): a, b = 0, 1 index = 0 while index < num: yield a a, b = b, a+b index += 1 return 'ok...' f = fib(100) while True: try: print(next(f... 阅读全文
posted @ 2018-09-13 16:50 Woowo 阅读(142) 评论(0) 推荐(0) 编辑
摘要: class ClassMate(object): def __init__(self): self.names = list() self.index = 0 def add(self,name): self.names.append(name) def __iter__(self): return se... 阅读全文
posted @ 2018-09-13 15:29 Woowo 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 多线程udp聊天器 阅读全文
posted @ 2018-09-12 22:27 Woowo 阅读(127) 评论(0) 推荐(0) 编辑