摘要:
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: ... 阅读全文
摘要:
shutil模块是高层次的文件接口,除了包含文件和目录的操作函数外,还包含里压缩包的创建和解压,支持的格式通过get_archive_formats()函数查询 In [57]: shutil.get_archive_formats() Out[57]: [('bztar', "bzip2'ed t 阅读全文
摘要:
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) ... 阅读全文