How to let Pool.map take a lambda function

前端 未结 4 1580
甜味超标
甜味超标 2020-12-01 07:27

I have the following function:

def copy_file(source_file, target_dir):
    pass

Now I would like to use multiprocessing to exe

4条回答
  •  一生所求
    2020-12-01 07:58

    For Python2.7+ or Python3, you could use functools.partial:

    import functools
    copier = functools.partial(copy_file, target_dir=target_dir)
    p.map(copier, file_list)
    

提交回复
热议问题