代码如下 test_dir = '/mnt/test_dir' mkdirlambda =lambda x: os.makedirs(x) if not os.path.exists(x) else True # 目录是否存在,不存在则创建 mkdirlambda(test_dir)