美容茌哪个网站做宣传好,关于建设企业网站的请示,scrm管理系统,网站要流量有什么用目录
安装依赖
代码
打包为可执行程序 如果你使用了Anaconda#xff0c;请先切换环境#xff01;#xff01;#xff01;
安装依赖
pip install tqdm aiofiles
代码
新建一个find.py文件#xff0c;将以下代码粘贴进去#xff1a;
import os
import datetime
f…目录
安装依赖
代码
打包为可执行程序 如果你使用了Anaconda请先切换环境
安装依赖
pip install tqdm aiofiles
代码
新建一个find.py文件将以下代码粘贴进去
import os
import datetime
from concurrent.futures import ThreadPoolExecutor
from tqdm import tqdmdef process_file(file_paths, year):count 0total_size 0for file_path in file_paths:try:file_time os.path.getmtime(file_path)if datetime.datetime.fromtimestamp(file_time).year year:total_size os.path.getsize(file_path)count 1except OSError as e:print(fError processing file {file_path}: {e})return count, total_sizedef find_files(target_dir, year, batch_size500):total_count 0total_size 0with ThreadPoolExecutor() as executor:futures []file_paths []with tqdm(desc正在收集文件, unit个) as progress:for root, dirs, files in os.walk(target_dir):for file in files:file_path os.path.join(root, file)file_paths.append(file_path)progress.update(1)if len(file_paths) batch_size:futures.append(executor.submit(process_file, file_paths, year))file_paths []# 添加剩余的 file_pathsfutures.append(executor.submit(process_file, file_paths, year))for f in tqdm(futures, descf处理任务每{batch_size}个文件为一个任务, unit个):count, size f.result()total_count counttotal_size sizereturn total_count, total_size# 获取用户输入
target_directory input(请输入目标目录: )
year int(input(请输入年份: ))file_count, total_size find_files(target_directory, year, batch_size1000)print(------------------------------------------------)
print(f{year}年文件总数量: {file_count})
print(f{year}年文件总占用: {(total_size / (1024 * 1024)):.2f} M | {(total_size / (1024 * 1024 * 1024)):.2f} G)
print(------------------------------------------------)
os.system(pause)运行
python find.py
打包为可执行程序
安装pyinstaller
pip install pyinstaller
然后运行以下命令在运行的目录中有一个dist文件夹可执行程序就在其中。
pyinstaller --onefile find.py
可执行程序已提供可自行下载
find.exe - 蓝奏云 点赞你的认可是我创作的动力 收藏你的青睐是我努力的方向 ✏️评论你的意见是我进步的财富