调用字程序sub_process= multiprocessing.process(target=copy_file,args=(file_name,source_dir,dest_dir))然后报错TypeError: 'module' object is not callable。 我得pip list有这个模块,为啥显示调用不了
4条回答 默认 最新
- CSDN专家-HGJ 2021-04-14 10:03关注
process 的P要大写,sub_process= multiprocessing.Process(target=copy_file,args=(file_name,source_dir,dest_dir));路径传入错误,改source_dir,dest_dir为source_path,dest_path;写入文件的地方没有传入写入内容。改成如下就能运行。
from multiprocessing import Process import os def copy_file(source_dir,dest_dir): file_list = os.listdir(source_dir) for file_name in file_list: source_path=source_dir+'/'+file_name dest_path=dest_dir+'/'+file_name with open(source_path,'rb') as source_file: with open(dest_path,'wb') as dest_file: while True: data=source_file.read(1024) if data: dest_file.write(source_file.read()) else: break if __name__ == '__main__': source_dir = 'F:/2021/answerQ/data/trainer' dest_dir = 'F:/2021/answerQ/data/2017' sub_process = Process(target=copy_file, args=(source_dir, dest_dir)) sub_process.start() sub_process.join()
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决评论 打赏 举报无用 1
悬赏问题
- ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
- ¥20 怎么用dlib库的算法识别小麦病虫害
- ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
- ¥15 java写代码遇到问题,求帮助
- ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
- ¥15 有了解d3和topogram.js库的吗?有偿请教
- ¥100 任意维数的K均值聚类
- ¥15 stamps做sbas-insar,时序沉降图怎么画
- ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
- ¥15 关于#Java#的问题,如何解决?