From 776a127b8db01cd4338f4db2a84ea567a65bff9f Mon Sep 17 00:00:00 2001 From: baoshiwei <baoshiwei@shlanbao.cn> Date: 星期二, 15 四月 2025 13:52:04 +0800 Subject: [PATCH] rjuq --- quchong.py | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-) diff --git a/quchong.py b/quchong.py index 3a27d70..d48414c 100644 --- a/quchong.py +++ b/quchong.py @@ -52,12 +52,9 @@ result = "涓ゅ紶鍥剧浉鍚�" return result -if __name__ == '__main__': - load_path = 'E:\yaocai\yinyanghuo' # 瑕佸幓閲嶇殑鏂囦欢澶� - save_path = 'E:\yaocai\\2\\yinyanghuo' # 绌烘枃浠跺す锛岀敤浜庡瓨鍌ㄦ娴嬪埌鐨勯噸澶嶇殑鐓х墖 +def quchongmethod(load_path, save_path): os.makedirs(save_path, exist_ok=True) - # 鑾峰彇鍥剧墖鍒楄〃 file_map锛屽瓧鍏竰鏂囦欢璺緞filename : 鏂囦欢澶у皬image_size} file_map = {} image_size = 0 @@ -70,13 +67,11 @@ # print('the full name of the file is %s' % os.path.join(parent, filename)) image_size = os.path.getsize(os.path.join(parent, filename)) file_map.setdefault(os.path.join(parent, filename), image_size) - # 鑾峰彇鐨勫浘鐗囧垪琛ㄦ寜 鏂囦欢澶у皬image_size 鎺掑簭 file_map = sorted(file_map.items(), key=lambda d: d[1], reverse=False) file_list = [] for filename, image_size in file_map: file_list.append(filename) - # 鍙栧嚭閲嶅鐨勫浘鐗� file_repeat = [] for currIndex, filename in enumerate(file_list): @@ -93,16 +88,22 @@ except Exception as e: pass - if(result == "涓ゅ紶鍥剧浉鍚�"): + if (result == "涓ゅ紶鍥剧浉鍚�"): file_repeat.append(file_list[currIndex + 1]) print("鐩稿悓鐨勫浘鐗囷細", file_list[currIndex], file_list[currIndex + 1]) else: print('涓嶅悓鐨勫浘鐗囷細', file_list[currIndex], file_list[currIndex + 1]) currIndex += 1 - if currIndex >= (len(file_list)-2): + if currIndex >= (len(file_list) - 2): break - # 灏嗛噸澶嶇殑鍥剧墖绉诲姩鍒版柊鐨勬枃浠跺す锛屽疄鐜板鍘熸枃浠跺す闄嶉噸 for image in file_repeat: shutil.move(image, save_path) - print("姝e湪绉婚櫎閲嶅鐓х墖锛�", image) \ No newline at end of file + print("姝e湪绉婚櫎閲嶅鐓х墖锛�", image) + + +if __name__ == '__main__': + + load_path = 'E:\yaocai\\chenpi' # 瑕佸幓閲嶇殑鏂囦欢澶� + save_path = 'E:\yaocai\\2\\chenpi' # 绌烘枃浠跺す锛岀敤浜庡瓨鍌ㄦ娴嬪埌鐨勯噸澶嶇殑鐓х墖 + quchongmethod(load_path,save_path) \ No newline at end of file -- Gitblit v1.9.3