|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 河蟹 于 2019-5-23 00:01 编辑
https://github.com/benmahr/RenZhengfei
从这个下载的文件
代码如下:
- import markdown
- import os
- import codecs
- head = """<!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
- <style type="text/css">
- code {
- color: inherit;
- background-color: rgba(0, 0, 0, 0.05);
- }
- </style>
- </head>
- <body>
- """
- foot = """
- </body>
- </html>
- """
- filepath = "G:\github_renzhengfei_26208\RenZhengfei"
- savepath = "G:\github_renzhengfei_26208\RenZhengfei\ALL-html"
- if not os.path.isdir(savepath):
- os.mkdir(savepath)
- os.chdir(savepath)
- i = 0
- pathDir = os.listdir(filepath)
- for allDir in pathDir:
- if (allDir == "pdf"):
- continue
- name = allDir
- print(name)
- os.chdir(filepath)
- fp1 = codecs.open(name, mode="r", encoding="utf-8")
- text = fp1.read()
- html = markdown.markdown(text)
- fp1.close()
-
- fname = name.replace('md', 'html')
-
- os.chdir(savepath)
- fp2 = codecs.open(fname, mode="w", encoding="utf-8", errors="xmlcharrefreplace")
- fp2.write(head + html + foot)
- fp2.close()
- print(i)
复制代码
错误信息:
|
-
|