因各种原因,我没有选择市面上比较火的知识管理软件,我要的是轻量级,本地,快速,无需登录,可编程。我尝试过通过Word,Excel管理文档,但总觉得打开太慢,打开速度最快的是txt文件,但是txt文件无法设置文本颜色,标记重点,所以最后我决定用html文档,通过硬编码的方式管理知识文档。一来熟悉一下html标签,二来html打开速度快,可以方便链接。
我建立了二级目录,一级目录是厂商和知识类型,比如华为、华三、思科、Linux。
二级目录是设备类型,比如交换机、路由器等
然后再在这些目录存放html格式的文章
通过运行根目录的python脚本,更新首页的目录
在添加或删除文档后,运行一下python脚本,就更新首页目录了
点击链接即可打开相应的文档。
最后,附上python脚本源代码,点我下载:
#-*-coding:utf-8-*-
import os
import traceback
before = ”'<!DOCTYPE html>
<html>
<head>
<meta charset=”utf-8″>
<title>首页</title>
<style type=”text/css”>
body {
margin:0 auto;
width:960px;
}
pre.blackwhite {
color: white;
background-color: black;
}
pre {
font-size: 1.1em;
font-family: Courier New;
}
section {
position: relative;
z-index: 1; /* needed for setting pseudo-element z-index */
overflow: hidden;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
section a {
position: relative;
display: inline-block;
outline: none;
color: #404d5b;
vertical-align: bottom;
text-decoration: none;
white-space: nowrap;
}
section a::before,
section a::after {
pointer-events: none;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-font-smoothing: antialiased;
font-smoothing: antialiased;
}
/* Fade in background */
.link-fadeinbg {
background: rgba(149,165,166,0.1);
}
.link-fadeinbg a {
border-bottom: 1px solid rgba(52,73,94,0.4);
font-weight: 500;
-webkit-transition: background-color 0.3s, border-color 0.3s;
transition: background-color 0.3s, border-color 0.3s;
}
.link-fadeinbg a:hover,
.link-fadeinbg a:focus {
border-color: rgba(52,73,94,0);
background-color: rgba(52,73,94,0.1);
}
</style>
</head>
<body>
<section class=”link-fadeinbg”>
<div>
”’
content = ”
after = ”’
</div>
</section>
</body>
</html>
”’
L1 = os.listdir(‘./’)
for dir in L1:
print(dir)
L1path = ‘./’ + dir
if os.path.isdir(L1path):
content += ‘<h1>’ + dir + ‘</h1>’
L2 = os.listdir(L1path)
for l2dir in L2:
L2path = L1path + ‘/’ + l2dir
if os.path.isdir(L2path):
print(L2path)
content += ‘<h3> ’ + l2dir + ‘<h3>’
L3 = os.listdir(L2path)
for l3file in L3:
fileurl = L2path + ‘/’ + l3file
print(fileurl)
(filesname, extension) = os.path.splitext(l3file)
content += ‘<p> <a href=”‘ + fileurl + ‘” target=”_blank”>’ + filesname + ‘</a></p>’
print(content)
with open(‘index.html’, ‘w’, encoding=’utf-8′) as f:
f.write(before)
f.write(content)
f.write(after)
f.close()
网络设备调试,网工技术交流: