提交 3e385efd 编写于 作者: 每日一练社区's avatar 每日一练社区

update lanqiaobei solution.md

上级 8384e776
......@@ -251,12 +251,60 @@ def modify_config_and_dir_name():
def modify_config_and_dir_name_new():
dirs = ['data/2.算法中阶', 'data/3.算法高阶']
exercises_ids = []
for dir in dirs:
dirs_ = os.listdir(dir)
algo_floor_dirs = []
for algo_floor_dir in dirs_:
leetcode_class_dir = os.path.join(dir, algo_floor_dir)
if os.path.isdir(leetcode_class_dir):
algo_floor_dirs.append(leetcode_class_dir)
for algo_floor_dir in algo_floor_dirs:
exercises_dirs_ = os.listdir(algo_floor_dir)
exercises_dirs = []
for exercises_dir_ in exercises_dirs_:
exercises_dir = os.path.join(algo_floor_dir, exercises_dir_)
if os.path.isdir(exercises_dir):
exercises_dirs.append(exercises_dir)
for idx, tem_dir in enumerate(exercises_dirs):
leetcode_title = tem_dir.split('/')[-1]
root_dir = '/'.join(tem_dir.split('/')[:-1])
new_dir_name = '{}.{}'.format(idx+1, leetcode_title)
new_dir_name = os.path.join(root_dir, new_dir_name)
os.rename(tem_dir, new_dir_name)
print(new_dir_name)
# print(len(exercises_dirs))
print(exercises_dirs)
# for exercises_dir in exercises_dirs:
# title = exercises_dir.split('/')[-1].split('.')[-1]
# root_dir = '/'.join(exercises_dir.split('/')[:-1])
# exercises_id = exercises_dir.split('/')[-1].split('.')[0]
# new_exercises_dir_name = '{}-{}'.format(int(exercises_id)+1, title)
# print(exercises_dir)
# print(title)
# print(exercises_id)
# print(new_exercises_dir_name)
# new_dst_dir_name = os.path.join(root_dir, new_exercises_dir_name)
# print(new_dst_dir_name)
# os.rename(exercises_dir, new_dst_dir_name)
# pass
if helper_function == 'count_tag_class':
count_tag_class()
if helper_function == 'count_exercises':
count_exercises()
if helper_function == 'modify_config_and_dir_name':
modify_config_and_dir_name()
if helper_function == 'modify_config_and_dir_name_new':
modify_config_and_dir_name_new()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册