There are some directory: directory
with subdirectories: QWER
, TYUI
, etc. In QWER
, TYUI
, etc there are files, for example, 1.log, 2.log, etc. I need process those.log files with 20 threads. Before that, I need to select 20.log files and process one file in one thread, is it correct? How to select 20 files from directories QWER
, TYUI
etc, if there may be less than 20 files per directory or more than 20 files?
import os
os.chdir('directory')
# Get the current directory, and for each file in the current directory get at most 20 files
files = [ os.listdir(x)[:20] for x in os.listdir('.')]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.