第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Python將大量文件錯(cuò)誤復(fù)制到許多打開(kāi)的文件中

Python將大量文件錯(cuò)誤復(fù)制到許多打開(kāi)的文件中

手掌心 2021-05-07 14:39:58
我正在嘗試將大量文件從一個(gè)目錄復(fù)制到另一個(gè)目錄。但是,在嘗試通過(guò)使用Threading加快處理速度時(shí),我收到一個(gè)錯(cuò)誤消息,它抱怨打開(kāi)的文件太多。目前,文件的測(cè)試批次大約為700多個(gè),下面是代碼。我該如何解決?在我的示例中,我將文件從網(wǎng)絡(luò)上的一個(gè)位置復(fù)制到同一網(wǎng)絡(luò)上的另一個(gè)位置,文件范圍從1mb到100mb。def copy_file_to_directory(file, directory):    '''    Description:        Copies the file to the supplied directory if it exists    '''    if os.path.isfile(file):        url = os.path.join(directory, os.path.basename(file))        try:            shutil.copyfile(file, url)            shutil.copystat(file, url)            return True        except IOError as e:            print (e)            return Falsedef copy_files_to_directory(files, directory):    '''    Directory:        Copy a list of files to directory, overwriting existing files    '''    if not os.path.isdir(directory):        os.makedirs(directory)    if not os.path.isdir(directory):        return False    workers = []       for x in files:        if os.path.isfile(x):            worker = threading.Thread(target=copy_file_to_directory, args=(x,directory))            workers.append(worker.start())    # wait until they are all done processing    for x in workers:        x.join()    return True files = [] # list of files copy_files_to_directory(files, 'C:/Users/John')
查看完整描述

2 回答

  • 2 回答
  • 0 關(guān)注
  • 151 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)