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

update leetcode deal code

上级 a97b25f7
......@@ -378,7 +378,7 @@ def leetcode_helper_add_sloutionjson():
def fix_bug():
data_dir = 'data_backup/3.蓝桥杯'
data_dir = 'data_backup/1.leetcode'
dirs_ = os.listdir(data_dir)
dirs = []
for dir in dirs_:
......@@ -388,15 +388,43 @@ def fix_bug():
for dir in dirs:
assert os.path.isdir(dir)
config_json_path = os.path.join(dir, 'config.json')
print(config_json_path)
solution_md_path = os.path.join(dir, 'solution.md')
if not os.path.exists(solution_md_path):
continue
with open(solution_md_path, 'r', encoding='utf-8') as f:
solution_md_data = f.read()
print(dir)
title = dir.split('/')[-1].split('-')[-1]
print(title)
solution_md_data = solution_md_data.replace('# 两数之和', '# {}'.format(title))
if solution_md_data.find('# {}\n\n'.format(title)) == -1:
solution_md_data = solution_md_data.replace('# {}'.format(title), '# {}\n'.format(title))
if solution_md_data.find('## aop\n\n') == -1:
solution_md_data = solution_md_data.replace('## aop', '## aop\n')
if solution_md_data.find('## 答案\n\n') == -1:
solution_md_data = solution_md_data.replace('## 答案', '## 答案\n')
if solution_md_data.find('## 选项\n\n') == -1:
solution_md_data = solution_md_data.replace('## 选项', '## 选项\n')
if solution_md_data.find('### before\n\n') == -1:
solution_md_data = solution_md_data.replace('### before', '### before\n')
if solution_md_data.find('### after\n\n') == -1:
solution_md_data = solution_md_data.replace('### after', '### after\n')
if solution_md_data.find('\n\n```cpp') == -1:
solution_md_data = solution_md_data.replace('```cpp', '\n```cpp')
if solution_md_data.find('\n\n### ') == -1:
solution_md_data = solution_md_data.replace('### ', '\n### ')
with open(solution_md_path, 'w', encoding='utf-8') as f:
f.write(solution_md_data)
with open(config_json_path, 'r', encoding='utf-8') as f:
config_data = json.load(f)
del config_data['title']
config_data_json = json.dumps(config_data, ensure_ascii=False, indent=2)
with open(config_json_path, 'w', encoding='utf-8') as f:
f.write(config_data_json)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册