Closed Zacharia2 closed 8 months ago
# -*- coding:utf-8 -*-
# py3
def list_split(list: list, n: int) -> list:
return [list[i : i + n] for i in range(0, len(list), n)]
if '__main__' == __name__:
list1 = ['s1', 's2', 's3', 's4', 's5', 's6', 's7']
# 将数组 list1 每 3 个切分一次
list2 = list_split(list1, 3)
print(list2)
多线程用不用都一样
多进程,感觉就像复制粘贴了多个py文件一起执行
异步也不能加快,因为是CPU密集型的任务
原来是文件读取的io等待问题导致的慢。用多线程等待。数据收集完成后在干别的。
concurrent.futures库
文件读取时间是大头。不能靠读取文件内容计算差异,而要避免这个。
最终可行性大概就是读取文件属性的最后修改时间,进行差异对比,筛选出来。
os.path.getmtime(filename)