
Centos的Apache部署web
前言 Apache程序是目前拥有很高市场占有率的Web服务程序之一,这里演示如何安装,并访问一个简单的index.html 开整 首先安装apache的软件包: ...

前言 Apache程序是目前拥有很高市场占有率的Web服务程序之一,这里演示如何安装,并访问一个简单的index.html 开整 首先安装apache的软件包: ...
安装 # 安装 yum install vsftpd -y yum install ftp -y # 启用 systemctl restart vsftpd systemctl enable vsftpd # 处理配置文件 mv /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak grep -v "#" /etc/vsftpd/vsftpd.conf.bak > /etc/vsftpd/vsftpd.conf # 关闭SELinux setenforce 0 修改配置文件: vim /etc/vsftpd/vsftpd.conf 将以下内容复制进去(注意!将18行 pasv_address 等号后面的ip改为你自己云服务器的ip地址!!) ...

Docker 是一个用于开发,交付和运行应用程序的开放平台。Docker 使您能够将应用程序与基础架构分开,从而可以快速交付软件。借助 Docker,您可以与管理应用程序相同的方式来管理基础架构。通过利用 Docker 的方法来快速交付,测试和部署代码,您可以大大减少编写代码和在生产环境中运行代码之间的延迟。 菜鸟教程--docker的优点 ...
CREATE TABLE Student( Sno Char(3) NOT NULL PRIMARY KEY, Sname CHAR(3) NOT NULL, Ssex CHAR(2) NOT NULL, Sbirthday datetime, Class CHAR(5) ) CREATE TABLE Teacher( Tno CHAR(3) PRIMARY KEY, Tname CHAR(4) NOT NULL, Tsex CHAR(2) NOT NULL, Tbirthday datetime, Prof CHAR(6), Depart VARCHAR(10) NOT NULL ) CREATE TABLE Course( Cno CHAR(5) NOT NULL PRIMARY KEY, Cname VARCHAR(10) NOT NULL, Tno CHAR(3) NOT NULL, FOREIGN KEY (Tno) REFERENCES Teacher(Tno) ) CREATE TABLE Score( Sno CHAR(3) NOT NULL, Cno CHAR(5) NOT NULL, Degree Decimal(4,1) FOREIGN KEY (Sno) REFERENCES Student(Sno), FOREIGN KEY (Cno) REFERENCES Course(Cno) )
思路 C++实在是弄不懂 代码 from typing import List, Optional class Node: """ 结点 """ def __init__(self): self.name: Optional[str] = None self.weight: Optional[int] = None self.left_child: Optional[Node] = None self.right_child: Optional[Node] = None self.parent: Optional[Node] = None class NodeCode: """ 结点的编码 """ def __init__(self, name: str, code: str): self.name = name self.code = code def __str__(self): return f"{self.name}:{self.code}" class HaffumanTreeCode: """ 哈夫曼树的编码 """ def __init__(self): self.code_list: List[NodeCode] = [] def append(self, code: NodeCode): self.code_list.append(code) def code(self, massage: str): """ 针对编码表编码 :param massage: 需要编码的信息 :return: """ code = "" for i in massage: for n in self.code_list: if n.name == i: code += n.code break # raise ValueError(f"'{i}'不存在") return code def decode(self, code: str): """ 针对编码表解码 :param code:需要解码的哈夫曼码 :return: """ out = "" i = 0 while code: code_need_match = code[0:i+1] for n in self.code_list: if n.code == code_need_match: out += n.name code = code[i+1:] i = 0 break i += 1 return out def __str__(self): """ 打印 :return: """ out = "" for i in self.code_list: out += i.__str__() + "\n" return out.strip() class HaffumanTree: """ 哈夫曼树 """ def __init__(self): self.root = Node() self.nodes: List[Node] = [] self.nodes_raw: List[Node] = [] self.codes: HaffumanTreeCode = HaffumanTreeCode() def inser(self, newnode: Node): for i in range(len(self.nodes)): if self.nodes[i].weight < newnode.weight: self.nodes.insert(i, newnode) return self.nodes.append(newnode) def build_tree(self, name_list: List[str], weight_list: List[int]): """ 创建哈夫曼树 :param name_list: 字符列表 :param weight_list: 权重列表 :return: """ # 队每个字符生成结点 while len(name_list) > 0: max_weight = max(weight_list) max_index = weight_list.index(max_weight) max_name = name_list[max_index] newnode = Node() newnode.name = max_name newnode.weight = max_weight self.nodes.append(newnode) name_list.remove(max_name) weight_list.remove(max_weight) # 保存源结点 self.nodes_raw = self.nodes[:] # 创建新结点并生成树 while len(self.nodes) > 2: left = self.nodes.pop() right = self.nodes.pop() newnode = Node() newnode.weight = left.weight + right.weight newnode.left_child = left newnode.right_child = right left.parent = newnode right.parent = newnode # 根据权重插入 self.inser(newnode) left = self.nodes.pop() right = self.nodes.pop() self.root.weight = left.weight + right.weight self.root.left_child = left self.root.right_child = right left.parent = self.root right.parent = self.root def make_code(self): """ 生成编码表 :return: """ while len(self.nodes_raw): node = self.nodes_raw.pop() name = node.name code = "" while node.parent != self.root: parent = node.parent if parent.left_child == node: code = "0" + code elif parent.right_child == node: code = "1" + code node = parent if self.root.left_child == node: code = "0" + code elif self.root.right_child == node: code = "1" + code self.codes.append(NodeCode(name, code)) def decode(self, code: str): return self.codes.decode(code) def code(self, massage: str): return self.codes.code(massage) if __name__ == '__main__': h = HaffumanTree() name_list = ["a", "b", "c", "d", "e"] wight_list = [5, 11, 6, 21, 19] h.build_tree(name_list, wight_list) h.make_code() print(f"编码表:\n{h.codes}") print(f'bcacce编码为:{h.code("bcacce")}') print(f'01001000001001解码为: {h.decode("0100100000100110")}')
安装 pip install PyMySQL 连接 db = pymysql.connect(host="192.168.1.1", port=3306, user="root", password="password", database="database_name") cursor = db.cursor() 查/增 sql_insert = """ INSERT INTO 表名(id, name, path) VALUES (%s, %s, %s) """ # 无论数据库数据类型为int或date,全部使用py的字符串形式插入,所以使用%s cursor.execute(sql_insert, (user_id, name, path)) # 这种可以有效避免因敏感字符而导致出现语法错误 db.commit() # 进行提交,否则无效 # 当数据源为http相关时,注意转义 import html from pymysql.converters import escape_string safe_data = escape_string(html.unescape(unsafe_data)) # unescape转义html字符,escape转义为可直接插入数据库的安全字符串 # 多数据一次插入 cursor.executemany(sql, info) # info可为list,循环按顺序进行插入 db.commit() 以及 因为图库已经快20g了,为了管理方便,顺便就上了mysql做数据管理,但有个问题,pymysql非异步,可能会造成bot的io堵塞,现在的数据量查询速度还算快,但要是时间久了就不一定; ...

轻量web服务 介绍 FastAPI 是一个用于构建 API 的现代、快速(高性能)的 web 框架,使用 Python 3.6+ 并基于标准的 Python 类型提示。 FastAPI 框架,高性能,易于学习,高效编码,生产可用 ...
介绍 Mediawiki是非常著名的开源wiki程序,比起之前的Dokuwiki功能要更完善,也更专业,使用PHP+SQL开发,适合用于构建百科、知识库、在线文档、个人笔记之类的应用。它的优点如下 美观的界面和可视化编辑器 拥有丰富的官方插件支持 官方文档非常完善,对中文支持也很友好 部署 我依旧是使用docker部署的,手动部署环境本次不介绍~~(不会)~~ ...
需求 我有几个小网站需要穿透出去,为了方便使用和安全,选择了直接使用Nginx实现反向代理和ssl的部署,另外还有一些简单的Nginx防护 反代实现 加密访问(仅本人访问) SSL部署 Nginx防护恶意请求 反代实现 server { listen 80; server_name www.your_url.com; location / { proxy_pass http://local456:port/; } } 这样就在80端口实现了对server_name 的反代操作,server_name填写外部请求的url,proxy_pass填写内部你需要反代出去的url ...
一般的多条件判断 if 判断1 and 判断2 and 判断3: run() 当语句非常长的时候,就显得难懂且不美观 all()方法多条件判断 if all([条件1, 条件2, 条件3]): run() all()传入一个可迭代对象,当所有条件为True时,返回True