摘要: [root@localhost python_install]# md5sum Python-3.7.2.tar.xz df6ec36011808205beda239c72f947cb Python-3.7.2.tar.xz [root@localhost python_install]# 阅读全文
posted @ 2019-03-19 17:03 superniao 阅读(595) 评论(0) 推荐(0) 编辑
摘要: def bytes2human(n): symbols = ('K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y') prefix = {} for i, s in enumerate(symbols): prefix[s] = 1 = prefix[s]: value = float(n) / prefix... 阅读全文
posted @ 2019-03-18 19:43 superniao 阅读(1593) 评论(0) 推荐(0) 编辑
摘要: from collections import namedtuple Disk = namedtuple('Disk', 'a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14') def get_disk_info(device): with open('diskstats') as f: for line in f: ... 阅读全文
posted @ 2019-03-17 20:45 superniao 阅读(199) 评论(0) 推荐(0) 编辑
摘要: output = subprocess.run(['df', '-h'],capture_output=True) outout.returncode #获取执行的状态码 0为正常 output.stdout.decode() #获取执行结果 默认结果为bytes类型,所需要decode 阅读全文
posted @ 2019-03-17 20:42 superniao 阅读(153) 评论(0) 推荐(0) 编辑
摘要: shutil模块是高层次的文件接口,除了包含文件和目录的操作函数外,还包含里压缩包的创建和解压,支持的格式通过get_archive_formats()函数查询 In [57]: shutil.get_archive_formats() Out[57]: [('bztar', "bzip2'ed t 阅读全文
posted @ 2019-03-17 17:01 superniao 阅读(169) 评论(0) 推荐(0) 编辑
摘要: tarfile中常用的函数: 1、getnames:获取tar包中的文件列表 2、extract: 提取单个文件 3、extractall : 提取所有文件 阅读全文
posted @ 2019-03-17 16:50 superniao 阅读(155) 评论(0) 推荐(0) 编辑
摘要: with open('file1', encoding='utf-8') as inf, open('file2', 'w', encoding='utf-8') as outf: for line in inf: print(*[ word for word in line.split()],file=outf) # outf.write(line) ... 阅读全文
posted @ 2019-03-16 19:58 superniao 阅读(254) 评论(0) 推荐(0) 编辑
摘要: 协程:能够在一个线程中实现并发的效果,能够规避一些任务中的IO操作,在任务中的执行过程中,检测到IO就切换到其他任务 阅读全文
posted @ 2018-12-16 22:01 superniao 阅读(108) 评论(0) 推荐(0) 编辑
摘要: import time from concurrent.futures import ThreadPoolExecutor def func(i): time.sleep(2) print(i) return i**2 tpool = ThreadPoolExecutor(max_workers = 5) t_lst = [] for i in range(10): ... 阅读全文
posted @ 2018-12-16 17:35 superniao 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 条件也可以理解为锁。也有acquire 、release、 wait、 notify方法 一个条件创建之初,默认有一个False状态,会影响wait一直处于等待状态 notify(int数据类型) 大白话就是制造几把钥匙 阅读全文
posted @ 2018-12-16 16:20 superniao 阅读(292) 评论(0) 推荐(0) 编辑