提交 fa0590eb 编写于 作者: ToTensor's avatar ToTensor

add code file

上级 87d3be30
__pycache__
\ No newline at end of file
...@@ -16,8 +16,6 @@ def extract_code(): ...@@ -16,8 +16,6 @@ def extract_code():
"全程软件测试(第3版)": "825acb73c85c4c4bb9632afe858bc097", "全程软件测试(第3版)": "825acb73c85c4c4bb9632afe858bc097",
} }
for book_idx, book_name in enumerate(book_mapping.keys()): for book_idx, book_name in enumerate(book_mapping.keys()):
if book_name == 'Python编程无师自通':
continue
book_dir_name = book_name book_dir_name = book_name
book_dir = os.path.join('data', book_dir_name) book_dir = os.path.join('data', book_dir_name)
if not os.path.exists(book_dir): if not os.path.exists(book_dir):
...@@ -70,7 +68,7 @@ def extract_code(): ...@@ -70,7 +68,7 @@ def extract_code():
if section.find(r'/') != -1: if section.find(r'/') != -1:
section = section.replace('/', '') section = section.replace('/', '')
section_dir = os.path.join(chapter_dir, section) section_dir = os.path.join(chapter_dir, section)
print(section_dir) # print(section_dir)
if not os.path.exists(section_dir): if not os.path.exists(section_dir):
os.mkdir(section_dir) os.mkdir(section_dir)
section_dir_list.append(section_dir) section_dir_list.append(section_dir)
...@@ -80,8 +78,8 @@ def extract_code(): ...@@ -80,8 +78,8 @@ def extract_code():
else: else:
html_save_path = os.path.join( html_save_path = os.path.join(
section_dir_list[idx - 1], 'text.html') section_dir_list[idx - 1], 'text.html')
with open(html_save_path, 'w', encoding='utf-8') as f: # with open(html_save_path, 'w', encoding='utf-8') as f:
f.write(section_content) # f.write(section_content)
code_list = re.findall(r'<code>(.*?)</code>', code_list = re.findall(r'<code>(.*?)</code>',
section_content, re.S) section_content, re.S)
...@@ -104,6 +102,7 @@ def extract_code(): ...@@ -104,6 +102,7 @@ def extract_code():
section_dir_list[idx - 1], section_dir_list[idx - 1],
'code_{}.java'.format(count)) 'code_{}.java'.format(count))
print(code_save_dir)
print(res_str) print(res_str)
with open(code_save_dir, 'w', encoding='utf-8') as f: with open(code_save_dir, 'w', encoding='utf-8') as f:
f.write(res_str) f.write(res_str)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册