赞
踩
原因:
仔细检查代码,原因是要创建的文件所在目录不存在导致的。
即:要创建/a/b/c/d.txt, 则需要先保证/a/b/c目录存在。
代码中先检测目录是否存在,不存在则先创建多级目录:
- if not os.path.exists(prefix_dir):
- os.makedirs(prefix_dir)
附:
创建多级目录:os.makedirs()
创建目录:os.mkdir()
创建文件:os.mknod()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。