itertools.productを使ってみたかったんです!!!
Python
1# -*- coding: utf8 -*-
2import itertools
3from pathlib import Path
4import shutil
5folder = 'X'
6
7
8def main():
9 target_dir = [Path(*p) for p in itertools.product(folder, 'abcd', 'st')]
10 for subdir in target_dir:
11 print(subdir)
12 shutil.rmtree(str(subdir))
13
14
15def test_create_dir():
16 for p in itertools.product(folder, 'abcd', 'stuv'):
17 subdir = Path(*p)
18 subdir.mkdir(parents=True, exist_ok=True)
19 #print(subdir)
20
21
22if __name__ == '__main__':
23 #test_create_dir()
24 main()
2018/02/05追記
ご要望の正規表現ではありませんが、改訂された質問内容に対応する削除処理を記載しておきます。
Python
1# -*- coding: utf8 -*-
2from itertools import starmap, product, repeat
3from pathlib import Path
4import shutil
5folder = 'X'
6
7
8def sub_dir() -> map:
9 return map(''.join, zip(repeat('a'), map(str, range(101))))
10
11
12def main() -> None:
13 for p in starmap(Path, product(folder, sub_dir(), 'st')):
14 print(p)
15 #shutil.rmtree(str(p))
16
17
18def test_create_dir() -> None:
19 for p in starmap(Path, product(folder, sub_dir(), 'stuv')):
20 p.mkdir(parents=True, exist_ok=True)
21
22
23if __name__ == '__main__':
24 # テストのためのディレクトリ作成!
25 #test_create_dir()
26 main()
27
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/02/04 14:26
2018/02/04 16:14