标签:指针 temp return ora flat sockets ken exp linux
import http.server
import socketserver
import os,io
import urllib
from http import HTTPStatus
import email.utils
import datetime
import json
import data
PORT = 8000
class do_Handler(http.server.SimpleHTTPRequestHandler):
def do_app(self):
pass
def global_request(self):
#print("____________________global_request______start")
#print("self.requestline: ",self.requestline)
path=urllib.parse.unquote(self.path)
#print("path: ",path)
self.canshu={}
path=path.split("?")
if len(path)>1:
for i in path[1].split("&"):
self.canshu[i.split("=")[0]]=i.split("=")[1]
#print("canshu: ",canshu)
#print("self.request: ",self.request)
#print("self.command: ",self.command)
if self.command=="POST":
#print("POST_____________")
#print("int(self.headers[‘content-length‘]): ",int(self.headers[‘content-length‘]))
req_datas = self.rfile.read(int(self.headers[‘content-length‘])) #重点在此步!
#print("self.rfile.read(int(self.headers[‘content-length‘])): ",req_datas.decode())
for i in req_datas.decode().split("&"):
self.canshu[i.split("=")[0]]=i.split("=")[1]
#print("canshu: ",canshu)
#print("POST_____________end")
#print("canshu: ",self.canshu)
#print("self.client_address: ",self.client_address)
#print("self.server: ",self.server)
#print("self.headers: ",self.headers)
#print("____________________global_request______end")
"""
____________________global_request______start
self.requestline: POST /test/test/ttt HTTP/1.1
path: /test/test/ttt
canshu: {}
self.request: <socket.socket fd=476, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=(‘127.0.0.1‘, 8000), raddr=(‘127.0.0.1‘, 52512)>
self.command: POST
POST_____________
int(self.headers[‘content-length‘]): 32
self.rfile.read(int(self.headers[‘content-length‘])): username=postman&password=123456
canshu: {‘username‘: ‘postman‘, ‘password‘: ‘123456‘}
POST_____________end
self.client_address: (‘127.0.0.1‘, 52512)
self.server: <socketserver.TCPServer object at 0x000001794669FD48>
self.headers: Host: localhost:8000
Connection: keep-alive
Content-Length: 32
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Accept: */*
Origin: chrome-extension://ojcehbbmmmlmlobapckckmgnhdmpmacc
Sec-Fetch-Site: none
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Cookie: _xsrf=2|21e063b3|84bfebbd08d32087174eee4a4d4d33ec|1607150430; username-localhost-8888="2|1:0|10:1607150550|23:username-localhost-8888|44:NjU1NzNlODUwYjQ0NDVmYzhmYzc3Zjg2MjQ1OGYzNTQ=|f787f4c6fb32f672faa8e72fa7bf68e7c8505085e331b7ec4915dd43ea7a533a"
____________________global_request______end
"""
return self.canshu
def do_GET(self):
self.global_request()
f = self.send_head()
if f:
try:
self.copyfile(f, self.wfile)
finally:
f.close()
#self.do_app()
for i in self.urls.keys():
if i==self.path.split(‘?‘,1)[0]:
app=getattr(self,self.urls[i])
app()
def send_head(self):
path = self.translate_path(self.path)
#print("path",path,self.path)
f = None
if os.path.isdir(path):
pass#return self.list_directory(path)
if not os.path.isfile(path):
return None
ctype = self.guess_type(path)
try:
if os.path.exists(path):
if os.path.splitext(path)[1]==".py":
f = open(path, ‘rb‘)
else:
f = open(path, ‘rb‘)
except OSError:
self.send_error(HTTPStatus.NOT_FOUND, "File not found")
return None
try:
fs = os.fstat(f.fileno())
self.send_response(HTTPStatus.OK)
self.send_header("Content-type", ctype)
self.send_header("Content-Length", str(fs[6]))
self.send_header("Last-Modified",
self.date_time_string(fs.st_mtime))
self.end_headers()
return f
except:
f.close()
raise
def do_POST(self):
self.global_request()
f = self.send_head()
if f:
try:
self.copyfile(f, self.wfile)
finally:
f.close()
#self.do_app()
for i in self.urls.keys():
if i==self.path.split(‘?‘,1)[0]:
app=getattr(self,self.urls[i])
app()
class app(do_Handler):
urls={
"/test":"test",
"/":"hello",
"/py":"do_py",
"/data_json":"data_json"
}
def hello(self):
self.send_response(200)
self.send_header(‘Content-type‘, ‘text/html‘)
self.end_headers()
self.wfile.write(b"hello hello()\r\n")
"""f = io.BytesIO()
f.write(b"hello world\r\n")
f.seek(0)
if f:
try:
self.copyfile(f, self.wfile)
finally:
f.close()"""
def do_py(self):
self.send_response(200)
self.send_header(‘Content-type‘, ‘text/html‘)
self.end_headers()
self.wfile.write(b"hello do_py()\r\n")
def test(self):
print(self.canshu)
self.send_response(200)
self.send_header(‘Content-type‘, ‘text/html‘)
self.end_headers()
#self.wfile.write(b"hello test()\r\n")
self.wfile.write(json.dumps(self.canshu).encode("utf-8"))
def data_json(self):
self.send_response(200)
self.send_header(‘Content-type‘, ‘text/html‘)
self.end_headers()
self.wfile.write(data.get_dataB(self.canshu))
with socketserver.TCPServer(("", PORT), app) as httpd:
print("serving at port", PORT)
httpd.serve_forever()
"""class tes:
def do_test(self):
print("do_test():")
method=getattr(tes,"do_test")
method(tes)"""
knowledge={
"编程":{
"c":["指针","数组","函数"],
"python":{"包":["Tkinter","pandas"]},
"网页":["js","css","html"],
"算法":{"排序算法":["冒泡","堆排","PID"]},
"机器学习":"Tensorflow"
},
"计算机":{"软件":{"系统":["linux","Windows"]},
"硬件":{"单片机":["stc51","esp8266"]},
"网络":["FTP","HTTP"]},
"生活":{"兴趣":"航模","感想":["爱情","生活","理想"]}
}
import json
import md_html
knowledge_data1=[]
def bianli(knowledge,tab):
for i in knowledge.keys():
print(tab*"\t",i,type(i),tab)
if type(knowledge[i])==dict:
bianli(knowledge[i],tab+1)
if type(knowledge[i])==list:
for ii in knowledge[i]:
print((tab+1)*"\t",ii,type(ii),tab)
elif type(knowledge[i])==str:
print((tab+1)*"\t",knowledge[i],type(knowledge[i]),tab)
def bianli1(knowledge,tab):
for i in knowledge.keys():
#print(tab*"\t",i,type(i),tab)
try:
knowledge_data1[tab].append(i)
except IndexError:
knowledge_data1.append([])
knowledge_data1[tab].append(i)
if type(knowledge[i])==dict:
bianli1(knowledge[i],tab+1)
if type(knowledge[i])==list:
for ii in knowledge[i]:
#print((tab+1)*"\t",ii,type(ii),tab+1)
try:
knowledge_data1[tab+1].append(ii)
except IndexError:
knowledge_data1.append([])
knowledge_data1[tab+1].append(ii)
elif type(knowledge[i])==str:
#print((tab+1)*"\t",knowledge[i],type(knowledge[i]),tab+1)
try:
knowledge_data1[tab+1].append(knowledge[i])
except IndexError:
knowledge_data1.append([])
knowledge_data1[tab+1].append(knowledge[i])
md_data={}
with open("data.json","r",encoding="utf-8") as f:
md_data=json.load(f)
def get_dataB(canshu):
c=canshu["json"]
if c=="nr2_0":
return str(knowledge.keys())[10:-1].replace("‘","\"").encode("utf-8")
if c=="nr2_1":
global knowledge_data1
knowledge_data1=[]
bianli1(knowledge,0)
return str(knowledge_data1).replace("‘","\"").encode("utf-8")
if c=="nr_ml":
return str(md_data["blml"].keys())[10:-1].replace("‘","\"").encode("utf-8")
if c=="mdhtml":
return md_html.create_html(canshu["data"]).encode("utf-8")
import markdown
md=markdown.Markdown(extensions=[‘markdown.extensions.fenced_code‘,‘markdown.extensions.tables‘])#Markdown 类实例
#重复调用它的 convert() 和 reset() 函数
"""print(html1)
md.reset()"""
def md_Z_html(canshu):
with open(canshu,‘r‘,encoding="utf-8", errors="xmlcharrefreplace") as f:
text=f.read()
md.reset()
html = md.convert(text)
return html
h1="""<html>
<head>
<meta charset="utf-8">
"""
style="""<style>
#tou{position:relative;min-width:500px;width:100%;height:60px;border-bottom:3px solid rgb(25,156,173);}.markdown-body{box-sizing:border-box;min-width:200px;max-width:980px;margin:0 auto;padding:45px;}.markdown-body .octicon{display:inline-block;fill:currentColor;vertical-align:text-bottom}.markdown-body .anchor{float:left;line-height:1;margin-left:-20px;padding-right:4px}.markdown-body .anchor:focus{outline:none}.markdown-body h1 .octicon-link,.markdown-body h2 .octicon-link,.markdown-body h3 .octicon-link,.markdown-body h4 .octicon-link,.markdown-body h5 .octicon-link,.markdown-body h6 .octicon-link{color:#1b1f23;vertical-align:middle;visibility:hidden}.markdown-body h1:hover .anchor,.markdown-body h2:hover .anchor,.markdown-body h3:hover .anchor,.markdown-body h4:hover .anchor,.markdown-body h5:hover .anchor,.markdown-body h6:hover .anchor{text-decoration:none}.markdown-body h1:hover .anchor .octicon-link,.markdown-body h2:hover .anchor .octicon-link,.markdown-body h3:hover .anchor .octicon-link,.markdown-body h4:hover .anchor .octicon-link,.markdown-body h5:hover .anchor .octicon-link,.markdown-body h6:hover .anchor .octicon-link{visibility:visible}.markdown-body h1:hover .anchor .octicon-link:before,.markdown-body h2:hover .anchor .octicon-link:before,.markdown-body h3:hover .anchor .octicon-link:before,.markdown-body h4:hover .anchor .octicon-link:before,.markdown-body h5:hover .anchor .octicon-link:before,.markdown-body h6:hover .anchor .octicon-link:before{width:16px;height:16px;content:‘ ‘;display:inline-block;background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCAxNiAxNicgdmVyc2lvbj0nMS4xJyB3aWR0aD0nMTYnIGhlaWdodD0nMTYnIGFyaWEtaGlkZGVuPSd0cnVlJz48cGF0aCBmaWxsLXJ1bGU9J2V2ZW5vZGQnIGQ9J000IDloMXYxSDRjLTEuNSAwLTMtMS42OS0zLTMuNVMyLjU1IDMgNCAzaDRjMS40NSAwIDMgMS42OSAzIDMuNSAwIDEuNDEtLjkxIDIuNzItMiAzLjI1VjguNTljLjU4LS40NSAxLTEuMjcgMS0yLjA5QzEwIDUuMjIgOC45OCA0IDggNEg0Yy0uOTggMC0yIDEuMjItMiAyLjVTMyA5IDQgOXptOS0zaC0xdjFoMWMxIDAgMiAxLjIyIDIgMi41UzEzLjk4IDEyIDEzIDEySDljLS45OCAwLTItMS4yMi0yLTIuNSAwLS44My40Mi0xLjY0IDEtMi4wOVY2LjI1Yy0xLjA5LjUzLTIgMS44NC0yIDMuMjVDNiAxMS4zMSA3LjU1IDEzIDkgMTNoNGMxLjQ1IDAgMy0xLjY5IDMtMy41UzE0LjUgNiAxMyA2eic+PC9wYXRoPjwvc3ZnPg==)}.markdown-body{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;line-height:1.5;color:#24292e;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;font-size:16px;line-height:1.5;word-wrap:break-word}.markdown-body details{display:block}.markdown-body summary{display:list-item}.markdown-body a{background-color:initial}.markdown-body a:active,.markdown-body a:hover{outline-width:0}.markdown-body strong{font-weight:inherit;font-weight:bolder}.markdown-body h1{font-size:2em;margin:.67em 0}.markdown-body img{border-style:none}.markdown-body code,.markdown-body kbd,.markdown-body pre{font-family:monospace,monospace;font-size:1em}.markdown-body hr{box-sizing:initial;height:0;overflow:visible}.markdown-body input{font:inherit;margin:0}.markdown-body input{overflow:visible}.markdown-body [type=checkbox]{box-sizing:border-box;padding:0}.markdown-body *{box-sizing:border-box}.markdown-body input{font-family:inherit;font-size:inherit;line-height:inherit}.markdown-body a{color:#0366d6;text-decoration:none}.markdown-body a:hover{text-decoration:underline}.markdown-body strong{font-weight:600}.markdown-body hr{height:0;margin:15px 0;overflow:hidden;background:0 0;border:0;border-bottom:1px solid #dfe2e5}.markdown-body hr:after,.markdown-body hr:before{display:table;content:""}.markdown-body hr:after{clear:both}.markdown-body table{border-spacing:0;border-collapse:collapse}.markdown-body td,.markdown-body th{padding:0}.markdown-body details summary{cursor:pointer}.markdown-body kbd{display:inline-block;padding:3px 5px;font:11px SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;line-height:10px;color:#444d56;vertical-align:middle;background-color:#fafbfc;border:1px solid #d1d5da;border-radius:3px;box-shadow:inset 0 -1px 0 #d1d5da}.markdown-body h1,.markdown-body h2,.markdown-body h3,.markdown-body h4,.markdown-body h5,.markdown-body h6{margin-top:0;margin-bottom:0}.markdown-body h1{font-size:32px}.markdown-body h1,.markdown-body h2{font-weight:600}.markdown-body h2{font-size:24px}.markdown-body h3{font-size:20px}.markdown-body h3,.markdown-body h4{font-weight:600}.markdown-body h4{font-size:16px}.markdown-body h5{font-size:14px}.markdown-body h5,.markdown-body h6{font-weight:600}.markdown-body h6{font-size:12px}.markdown-body p{margin-top:0;margin-bottom:10px}.markdown-body blockquote{margin:0}.markdown-body ol,.markdown-body ul{padding-left:0;margin-top:0;margin-bottom:0}.markdown-body ol ol,.markdown-body ul ol{list-style-type:lower-roman}.markdown-body ol ol ol,.markdown-body ol ul ol,.markdown-body ul ol ol,.markdown-body ul ul ol{list-style-type:lower-alpha}.markdown-body dd{margin-left:0}.markdown-body code,.markdown-body pre{font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;font-size:12px}.markdown-body pre{margin-top:0;margin-bottom:0}.markdown-body input::-webkit-inner-spin-button,.markdown-body input::-webkit-outer-spin-button{margin:0;-webkit-appearance:none;appearance:none}.markdown-body:checked+.radio-label{position:relative;z-index:1;border-color:#0366d6}.markdown-body .border{border:1px solid #e1e4e8 !important}.markdown-body .border-0{border:0 !important}.markdown-body .border-bottom{border-bottom:1px solid #e1e4e8 !important}.markdown-body .rounded-1{border-radius:3px !important}.markdown-body .bg-white{background-color:#fff !important}.markdown-body .bg-gray-light{background-color:#fafbfc !important}.markdown-body .text-gray-light{color:#6a737d !important}.markdown-body .mb-0{margin-bottom:0 !important}.markdown-body .my-2{margin-top:8px !important;margin-bottom:8px !important}.markdown-body .pl-0{padding-left:0 !important}.markdown-body .py-0{padding-top:0 !important;padding-bottom:0 !important}.markdown-body .pl-1{padding-left:4px !important}.markdown-body .pl-2{padding-left:8px !important}.markdown-body .py-2{padding-top:8px !important;padding-bottom:8px !important}.markdown-body .pl-3,.markdown-body .px-3{padding-left:16px !important}.markdown-body .px-3{padding-right:16px !important}.markdown-body .pl-4{padding-left:24px !important}.markdown-body .pl-5{padding-left:32px !important}.markdown-body .pl-6{padding-left:40px !important}.markdown-body .f6{font-size:12px !important}.markdown-body .lh-condensed{line-height:1.25 !important}.markdown-body .text-bold{font-weight:600 !important}.markdown-body .pl-c{color:#6a737d}.markdown-body .pl-c1,.markdown-body .pl-s .pl-v{color:#005cc5}.markdown-body .pl-e,.markdown-body .pl-en{color:#6f42c1}.markdown-body .pl-s .pl-s1,.markdown-body .pl-smi{color:#24292e}.markdown-body .pl-ent{color:#22863a}.markdown-body .pl-k{color:#d73a49}.markdown-body .pl-pds,.markdown-body .pl-s,.markdown-body .pl-s .pl-pse .pl-s1,.markdown-body .pl-sr,.markdown-body .pl-sr .pl-cce,.markdown-body .pl-sr .pl-sra,.markdown-body .pl-sr .pl-sre{color:#032f62}.markdown-body .pl-smw,.markdown-body .pl-v{color:#e36209}.markdown-body .pl-bu{color:#b31d28}.markdown-body .pl-ii{color:#fafbfc;background-color:#b31d28}.markdown-body .pl-c2{color:#fafbfc;background-color:#d73a49}.markdown-body .pl-c2:before{content:"^M"}.markdown-body .pl-sr .pl-cce{font-weight:700;color:#22863a}.markdown-body .pl-ml{color:#735c0f}.markdown-body .pl-mh,.markdown-body .pl-mh .pl-en,.markdown-body .pl-ms{font-weight:700;color:#005cc5}.markdown-body .pl-mi{font-style:italic;color:#24292e}.markdown-body .pl-mb{font-weight:700;color:#24292e}.markdown-body .pl-md{color:#b31d28;background-color:#ffeef0}.markdown-body .pl-mi1{color:#22863a;background-color:#f0fff4}.markdown-body .pl-mc{color:#e36209;background-color:#ffebda}.markdown-body .pl-{color:#f6f8fa;background-color:#005cc5}.markdown-body .pl-mdr{font-weight:700;color:#6f42c1}.markdown-body .pl-ba{color:#586069}.markdown-body .pl-sg{color:#959da5}.markdown-body .pl-corl{text-decoration:underline;color:#032f62}.markdown-body .mb-0{margin-bottom:0 !important}.markdown-body .my-2{margin-bottom:8px !important}.markdown-body .my-2{margin-top:8px !important}.markdown-body .pl-0{padding-left:0 !important}.markdown-body .py-0{padding-top:0 !important;padding-bottom:0 !important}.markdown-body .pl-1{padding-left:4px !important}.markdown-body .pl-2{padding-left:8px !important}.markdown-body .py-2{padding-top:8px !important;padding-bottom:8px !important}.markdown-body .pl-3{padding-left:16px !important}.markdown-body .pl-4{padding-left:24px !important}.markdown-body .pl-5{padding-left:32px !important}.markdown-body .pl-6{padding-left:40px !important}.markdown-body .pl-7{padding-left:48px !important}.markdown-body .pl-8{padding-left:64px !important}.markdown-body .pl-9{padding-left:80px !important}.markdown-body .pl-10{padding-left:96px !important}.markdown-body .pl-11{padding-left:112px !important}.markdown-body .pl-12{padding-left:128px !important}.markdown-body hr{border-bottom-color:#eee}.markdown-body kbd{display:inline-block;padding:3px 5px;font:11px SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;line-height:10px;color:#444d56;vertical-align:middle;background-color:#fafbfc;border:1px solid #d1d5da;border-radius:3px;box-shadow:inset 0 -1px 0 #d1d5da}.markdown-body:after,.markdown-body:before{display:table;content:""}.markdown-body:after{clear:both}.markdown-body>:first-child{margin-top:0 !important}.markdown-body>:last-child{margin-bottom:0 !important}.markdown-body a:not([href]){color:inherit;text-decoration:none}.markdown-body blockquote,.markdown-body details,.markdown-body dl,.markdown-body ol,.markdown-body p,.markdown-body pre,.markdown-body table,.markdown-body ul{margin-top:0;margin-bottom:16px}.markdown-body hr{height:.25em;padding:0;margin:24px 0;background-color:#e1e4e8;border:0}.markdown-body blockquote{padding:0 1em;color:#6a737d;border-left:.25em solid #dfe2e5}.markdown-body blockquote>:first-child{margin-top:0}.markdown-body blockquote>:last-child{margin-bottom:0}.markdown-body h1,.markdown-body h2,.markdown-body h3,.markdown-body h4,.markdown-body h5,.markdown-body h6{margin-top:24px;margin-bottom:16px;font-weight:600;line-height:1.25}.markdown-body h1{font-size:2em}.markdown-body h1,.markdown-body h2{padding-bottom:.3em;border-bottom:1px solid #eaecef}.markdown-body h2{font-size:1.5em}.markdown-body h3{font-size:1.25em}.markdown-body h4{font-size:1em}.markdown-body h5{font-size:.875em}.markdown-body h6{font-size:.85em;color:#6a737d}.markdown-body ol,.markdown-body ul{padding-left:2em}.markdown-body ol ol,.markdown-body ol ul,.markdown-body ul ol,.markdown-body ul ul{margin-top:0;margin-bottom:0}.markdown-body li{word-wrap:break-all}.markdown-body li>p{margin-top:16px}.markdown-body li+li{margin-top:.25em}.markdown-body dl{padding:0}.markdown-body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:600}.markdown-body dl dd{padding:0 16px;margin-bottom:16px}.markdown-body table{display:block;width:100%;overflow:auto}.markdown-body table th{font-weight:600}.markdown-body table td,.markdown-body table th{padding:6px 13px;border:1px solid #dfe2e5}.markdown-body table tr{background-color:#fff;border-top:1px solid #c6cbd1}.markdown-body table tr:nth-child(2n){background-color:#f6f8fa;}.markdown-body img{max-width:100%;box-sizing:initial;background-color:#fff}.markdown-body img[align=right]{padding-left:20px}.markdown-body img[align=left]{padding-right:20px}.markdown-body code{padding:.2em .4em;margin:0;font-size:85%;border-radius:3px}.markdown-body pre{word-wrap:normal}.markdown-body pre>code{padding:0;margin:0;font-size:100%;word-break:normal;white-space:pre;border:0}.markdown-body .highlight{margin-bottom:16px}.markdown-body .highlight pre{margin-bottom:0;word-break:normal}.markdown-body .highlight pre,.markdown-body pre{padding:16px;overflow:auto;font-size:85%;line-height:1.45;border-radius:3px}.markdown-body pre code{max-width:auto;padding:0;margin:0;overflow:visible;line-height:inherit;word-wrap:normal;border:0}.markdown-body .commit-tease-sha{display:inline-block;font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;font-size:90%;color:#444d56}.markdown-body .full-commit .btn-outline:not(:disabled):hover{color:#005cc5;border-color:#005cc5}.markdown-body .blob-wrapper{overflow-x:auto;overflow-y:hidden}.markdown-body .blob-wrapper-embedded{max-height:240px;overflow-y:auto}.markdown-body .blob-num{width:1%;min-width:50px;padding-right:10px;padding-left:10px;font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;font-size:12px;line-height:20px;color:rgba(27,31,35,.3);text-align:right;white-space:nowrap;vertical-align:top;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.markdown-body .blob-num:hover{color:rgba(27,31,35,.6)}.markdown-body .blob-num:before{content:attr(data-line-number)}.markdown-body .blob-code{position:relative;padding-right:10px;padding-left:10px;line-height:20px;vertical-align:top}.markdown-body .blob-code-inner{overflow:visible;font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;font-size:12px;color:#24292e;word-wrap:normal;white-space:pre}.markdown-body .pl-token.active,.markdown-body .pl-token:hover{cursor:pointer;background:#ffea7f}.markdown-body .tab-size[data-tab-size="1"]{-moz-tab-size:1;tab-size:1}.markdown-body .tab-size[data-tab-size="2"]{-moz-tab-size:2;tab-size:2}.markdown-body .tab-size[data-tab-size="3"]{-moz-tab-size:3;tab-size:3}.markdown-body .tab-size[data-tab-size="4"]{-moz-tab-size:4;tab-size:4}.markdown-body .tab-size[data-tab-size="5"]{-moz-tab-size:5;tab-size:5}.markdown-body .tab-size[data-tab-size="6"]{-moz-tab-size:6;tab-size:6}.markdown-body .tab-size[data-tab-size="7"]{-moz-tab-size:7;tab-size:7}.markdown-body .tab-size[data-tab-size="8"]{-moz-tab-size:8;tab-size:8}.markdown-body .tab-size[data-tab-size="9"]{-moz-tab-size:9;tab-size:9}.markdown-body .tab-size[data-tab-size="10"]{-moz-tab-size:10;tab-size:10}.markdown-body .tab-size[data-tab-size="11"]{-moz-tab-size:11;tab-size:11}.markdown-body .tab-size[data-tab-size="12"]{-moz-tab-size:12;tab-size:12}.markdown-body .task-list-item{list-style-type:none}.markdown-body .task-list-item+.task-list-item{margin-top:3px}.markdown-body .task-list-item input{margin:0 .2em .25em -1.6em;vertical-align:middle}.markdown-body pre code,.item-content pre code,.markdown-body pre .subst,.item-content pre .subst,.markdown-body pre .tag .title,.item-content pre .tag .title,.markdown-body pre .lisp .title,.item-content pre .lisp .title,.markdown-body pre .clojure .built_in,.item-content pre .clojure .built_in,.markdown-body pre .nginx .title,.item-content pre .nginx .title{}.markdown-body pre .string,.item-content pre .string,.markdown-body pre .title,.item-content pre .title,.markdown-body pre .constant,.item-content pre .constant,.markdown-body pre .parent,.item-content pre .parent,.markdown-body pre .tag .value,.item-content pre .tag .value,.markdown-body pre .rules .value,.item-content pre .rules .value,.markdown-body pre .rules .value .number,.item-content pre .rules .value .number,.markdown-body pre .preprocessor,.item-content pre .preprocessor,.markdown-body pre .ruby .symbol,.item-content pre .ruby .symbol,.markdown-body pre .ruby .symbol .string,.item-content pre .ruby .symbol .string,.markdown-body pre .aggregate,.item-content pre .aggregate,.markdown-body pre .template_tag,.item-content pre .template_tag,.markdown-body pre .django .variable,.item-content pre .django .variable,.markdown-body pre .smalltalk .class,.item-content pre .smalltalk .class,.markdown-body pre .addition,.item-content pre .addition,.markdown-body pre .flow,.item-content pre .flow,.markdown-body pre .stream,.item-content pre .stream,.markdown-body pre .bash .variable,.item-content pre .bash .variable,.markdown-body pre .apache .tag,.item-content pre .apache .tag,.markdown-body pre .apache .cbracket,.item-content pre .apache .cbracket,.markdown-body pre .tex .command,.item-content pre .tex .command,.markdown-body pre .tex .special,.item-content pre .tex .special,.markdown-body pre .erlang_repl .function_or_atom,.item-content pre .erlang_repl .function_or_atom,.markdown-body pre .markdown .header,.item-content pre .markdown .header{color:#df5000}.markdown-body pre .comment,.item-content pre .comment,.markdown-body pre .annotation,.item-content pre .annotation,.markdown-body pre .template_comment,.item-content pre .template_comment,.markdown-body pre .diff .header,.item-content pre .diff .header,.markdown-body pre .chunk,.item-content pre .chunk,.markdown-body pre .markdown .blockquote,.item-content pre .markdown .blockquote{color:#888}.markdown-body pre .number,.item-content pre .number,.markdown-body pre .date,.item-content pre .date,.markdown-body pre .regexp,.item-content pre .regexp,.markdown-body pre .literal,.item-content pre .literal,.markdown-body pre .smalltalk .symbol,.item-content pre .smalltalk .symbol,.markdown-body pre .smalltalk .char,.item-content pre .smalltalk .char,.markdown-body pre .go .constant,.item-content pre .go .constant,.markdown-body pre .change,.item-content pre .change,.markdown-body pre .markdown .bullet,.item-content pre .markdown .bullet,.markdown-body pre .markdown .link_url,.item-content pre .markdown .link_url{color:#080}.markdown-body pre .label,.item-content pre .label,.markdown-body pre .javadoc,.item-content pre .javadoc,.markdown-body pre .ruby .string,.item-content pre .ruby .string,.markdown-body pre .decorator,.item-content pre .decorator,.markdown-body pre .filter .argument,.item-content pre .filter .argument,.markdown-body pre .localvars,.item-content pre .localvars,.markdown-body pre .array,.item-content pre .array,.markdown-body pre .attr_selector,.item-content pre .attr_selector,.markdown-body pre .important,.item-content pre .important,.markdown-body pre .pseudo,.item-content pre .pseudo,.markdown-body pre .pi,.item-content pre .pi,.markdown-body pre .doctype,.item-content pre .doctype,.markdown-body pre .deletion,.item-content pre .deletion,.markdown-body pre .envvar,.item-content pre .envvar,.markdown-body pre .shebang,.item-content pre .shebang,.markdown-body pre .apache .sqbracket,.item-content pre .apache .sqbracket,.markdown-body pre .nginx .built_in,.item-content pre .nginx .built_in,.markdown-body pre .tex .formula,.item-content pre .tex .formula,.markdown-body pre .erlang_repl .reserved,.item-content pre .erlang_repl .reserved,.markdown-body pre .prompt,.item-content pre .prompt,.markdown-body pre .markdown .link_label,.item-content pre .markdown .link_label,.markdown-body pre .vhdl .attribute,.item-content pre .vhdl .attribute,.markdown-body pre .clojure .attribute,.item-content pre .clojure .attribute,.markdown-body pre .coffeescript .property,.item-content pre .coffeescript .property{color:#88f}.markdown-body pre .keyword,.item-content pre .keyword{color:#48b;font-weight:bold}.markdown-body pre .title,.item-content pre .title{color:#454545}.markdown-body pre .markdown .emphasis,.item-content pre .markdown .emphasis,.markdown-body pre .comment,.item-content pre .comment{font-style:italic}.markdown-body pre .nginx .built_in,.item-content pre .nginx .built_in{font-weight:normal}.markdown-body pre .coffeescript .javascript,.item-content pre .coffeescript .javascript,.markdown-body pre .javascript .xml,.item-content pre .javascript .xml,.markdown-body pre .tex .formula,.item-content pre .tex .formula,.markdown-body pre .xml .javascript,.item-content pre .xml .javascript,.markdown-body pre .xml .vbscript,.item-content pre .xml .vbscript,.markdown-body pre .xml .css,.item-content pre .xml .css,.markdown-body pre .xml .cdata,.item-content pre .xml .cdata{opacity:0.5}.markdown-body ul,.item-content ul{margin:0.5em 0;padding:0 0 0 2em}.markdown-body ul li,.item-content ul li{list-style:disc}.hljs{display:block;overflow-x:auto;padding:0.5em;color:#333;background:#f8f8f8;}.hljs-comment,.hljs-quote{color:#998;font-style:italic;}.hljs-keyword,.hljs-selector-tag,.hljs-subst{color:#333;font-weight:bold;}.hljs-number,.hljs-literal,.hljs-variable,.hljs-template-variable,.hljs-tag .hljs-attr{color:#008080;}.hljs-string,.hljs-doctag{color:#d14;}.hljs-title,.hljs-section,.hljs-selector-id{color:#900;font-weight:bold;}.hljs-subst{font-weight:normal;}.hljs-type,.hljs-class .hljs-title{color:#458;font-weight:bold;}.hljs-tag,.hljs-name,.hljs-attribute{color:#000080;font-weight:normal;}.hljs-regexp,.hljs-link{color:#009926;}.hljs-symbol,.hljs-bullet{color:#990073;}.hljs-built_in,.hljs-builtin-name{color:#0086b3;}.hljs-meta{color:#999;font-weight:bold;}.hljs-deletion{background:#fdd;}.hljs-addition{background:#dfd;}.hljs-emphasis{font-style:italic;}.hljs-strong{font-weight:bold;}</style>
"""
h2=""" <link rel="stylesheet" href="highlight/styles/default.css">
<link rel="stylesheet" href="highlight/styles/stackoverflow-dark.css">
<script src="highlight/highlight.pack.js">
/*
Fancy style (c) John Smith <email@domain.com>
*/
</script>
<script>
hljs.initHighlightingOnLoad();
</script>
</head>
<body>
<div id="tou">
<a href="index.html">
Index.html</a>
</div>
<div class="markdown-body">
"""
js1="""<script>
/* $(document).ready(function (){
$("pre code").each(function (i,block){
hljs.highlightBlock(block);
});
});
*/
document.addEventListener(‘DOMContentLoaded‘, (event) => {
document.querySelectorAll(‘pre code‘).forEach((block) => {
hljs.highlightBlock(block);
});
});
</script>
"""
h3="""</div>
</body>
</html>
"""
def create_html(cansh):
mdhtml=md_Z_html(cansh)
return h1+style+h2+mdhtml+js1+h3
"""with open(‘test.html‘,‘w‘,encoding="utf-8") as f:
f.write(h1+style+h2+mdhtml+js1+h3)"""
标签:指针 temp return ora flat sockets ken exp linux
原文地址:https://www.cnblogs.com/createhm/p/14181541.html