#! /usr/bin/python
# -*- coding:utf-8 -*-
'''
------------------------------------------
function:
多线程复制图片
author: bingo
created: 2020-01-03
------------------------------------------
'''
from Queue import Queue
import threading
import shutil
import os
import time
count = 0
DEFAULT_THREAD_NUM = 10
file_dir = './11-bak'
fl = 'f.list'
target_dir = './11_copy/'
def ensure_dir_exits(path):
try:
os.makedirs(path)
except OSError:
if not os.path.isdir(path):
raise
def generate_list(file_dir):
global count
f = open(fl, 'w+')
for root, dirs, files in os.walk(file_dir):
for each in files:
count += 1
f_name = os.path.join(root,each)
f.write(f_name + '\n')
f.close()
def generate_file_copy_func():
def file_copy_func(file1):
file2 = target_dir + os.path.base
初学Python:多线程脚本-使用Thread类创建(from threading import Thread)
最新推荐文章于 2023-04-28 10:02:35 发布
本文适合Python初学者,讲解如何利用`threading.Thread`类创建多线程脚本,深入理解Python并发执行的概念。
摘要由CSDN通过智能技术生成