判断名为 dir 的文件夹是否存在,不存在则创建 dir_name = 'dir' if not os.path.exists(dir_name): # os模块判断并创建 os.mkdir(dir_name)