我希望我的多处理Python脚本在控制台上显示其当前进度;例如:
5个文件中有3个已完成
我的脚本(不完整):
import concurrent.futures
def main(file):
# do stuff with file
sys.stdout.write("\r%d of %d files finished" % (count, total))
if __name__ == '__main__':
files = ['a','b','c','d','e']
with concurrent.futures.ProcessPoolExecutor() as executor:
executor.map(main, files)
问题-如何修改我的脚本,使其: