摘要: 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) 编辑