- 论坛徽章:
- 54
|
本帖最后由 haooooaaa 于 2014-12-05 13:58 编辑
- >>> os.listdir('/tmp/abc')
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- OSError: [Errno 2] No such file or directory: '/tmp/abc'
- >>> os.system(r"mkdir -p /tmp/abc/{a,b,c}")
- 0
- >>> os.listdir('/tmp/abc')
- ['{a,b,c}']
- >>> subprocess.call(r'mkdir -p /tmp/abc/{a,b,c}', shell=True)
- 0
- >>> os.listdir('/tmp/abc')
- ['{a,b,c}']
复制代码 如上, 在/tmp 创建目录 abc, 此目录 下再合建 a,b,c 但似乎不行,
直接在 shell 可以的,
python 版本 2.7.3
系统 ubuntu 12.04
直接shell- user@test:/tmp$ ls abc
- {a,b,c}
- user@test:/tmp$ mkdir -p abc/{a,b,c}
- user@test:/tmp$ ls abc
- a {a,b,c} b c
复制代码 |
|