【发布时间】:2018-01-15 04:01:59
【问题描述】:
我正在尝试使用 Python 脚本递归地创建目录,但出现错误。
代码:
import os
a = "abc"
os.makedirs('/root/test_{}'.format(a), exist_ok=True)
错误:
Traceback (most recent call last): File "mk.py", line 3, in <module> os.makedirs('/root/test_{}'.format(a), exist_ok=True) TypeError: makedirs() got an unexpected keyword argument 'exist_ok'
我使用的是python2.7,上面的选项在这个版本中不起作用?如果不是,什么是替代解决方案?
【问题讨论】:
-
exist_ok在 3.2 版中是“新”
标签: python linux python-2.7