摘要: 文档地址:https://www.cse.huji.ac.il/course/2004/com1/Exercises/Ex4/I.O.models.pdf 五种I/O模型: 1. blocking I/O 阻塞I/O 2. nonblocking I/O 非阻塞I/O 3. I/O multiple 阅读全文
posted @ 2019-12-22 23:42 wztshine 阅读(540) 评论(0) 推荐(0) 编辑
摘要: 套接字(socket)是一个抽象层,应用程序可以通过它发送或接收数据,可对其进行像对文件一样的打开、读写和关闭等操作。 1. 实现客户端发送字符,服务器返回大写的字符: 服务器: import socketserver class MyTCPHandler(socketserver.BaseRequ 阅读全文
posted @ 2019-12-22 12:50 wztshine 阅读(1320) 评论(0) 推荐(0) 编辑
摘要: 手动协程操作: # pip install gevent from greenlet import greenlet def test(): print('He ') gr2.switch() # 切换到test2 print('a ') gr2.switch() def test2(): prin 阅读全文
posted @ 2019-12-17 13:52 wztshine 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 官方文档地址:https://openpyxl.readthedocs.io/en/stable/tutorial.html 1. 加载excel import openpyxl from openpyxl.utils import get_column_letter,column_index_fr 阅读全文
posted @ 2019-12-09 15:27 wztshine 阅读(1622) 评论(0) 推荐(0) 编辑
摘要: import os import zipfile def zipDir(dirpath,outFullName): """ 压缩指定文件夹 :param dirpath: 目标文件夹路径 :param outFullName: 压缩文件保存路径+xxxx.zip """ zip = zipfile. 阅读全文
posted @ 2019-12-09 10:38 wztshine 阅读(349) 评论(0) 推荐(0) 编辑
摘要: 1. 进程 # 这段代码在pycharm中可能不出结果,可以放到cmd中运行 import threading import multiprocessing import time def subTest(): print('This is in Process:%s thread: %s' % ( 阅读全文
posted @ 2019-12-03 22:06 wztshine 阅读(366) 评论(0) 推荐(0) 编辑
摘要: 语法: CREATE FUNCTION <函数名> ( [ <参数1> <类型1> [ , <参数2> <类型2>] ] … ) RETURNS <类型> # 返回的数据类型 return <函数主体> e.g. mysql> set global log_bin_trust_function_cr 阅读全文
posted @ 2019-12-03 16:03 wztshine 阅读(129) 评论(0) 推荐(0) 编辑
摘要: Queue 是 python 标准库中的线程安全的队列(FIFO)实现, 提供了一个适用于多线程编程的先进先出的数据结构 队列类型 先入先出、后入先出、优先级队列 # 普通队列,先入先出,maxsize=0意味着队列没有上限 q0 = queue.Queue(maxsize=2) # last in 阅读全文
posted @ 2019-12-02 13:28 wztshine 阅读(1043) 评论(0) 推荐(0) 编辑
摘要: ## 1. 多线程的基本使用 ```python import threading import time def run(num): print('Num: %s'% num) time.sleep(3) if num == 4: print('Thread is finished.') # 对函 阅读全文
posted @ 2019-12-01 14:25 wztshine 阅读(606) 评论(0) 推荐(0) 编辑
摘要: 1. SFTP基于 用户名密码 登录服务器,实现上传下载: import paramiko transport = paramiko.Transport(('hostname', 22)) # 生成trasport,配置主机名,端口 transport.connect(username='root' 阅读全文
posted @ 2019-11-30 22:35 wztshine 阅读(1033) 评论(0) 推荐(0) 编辑
摘要: 视图是一张虚拟表,是从一个或多个表中导出的表,其数据其实存储在其引用的表中,本身并没有实际的数据。删除和创建视图,对其引用的表没有什么影响。 视图的缺点是可能会降低查询性能。 1. 创建视图 CREATE VIEW <视图名> AS <SELECT语句> e.g. # 不写字段名,则默认使用引用的表 阅读全文
posted @ 2019-11-29 16:23 wztshine 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 一、插入数据 1. INSERT ... VALUES ... INSERT INTO <表名> [ <列名1> [ , … <列名n>] ] VALUES (值1) [… , (值n) ]; 针对特定字段添加数据: mysql> insert into user -> (id,name,passw 阅读全文
posted @ 2019-11-29 13:10 wztshine 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 1. 基本语法: SELECT {* | <字段列名>} [ FROM <表 1>, <表 2>… [WHERE <表达式> [GROUP BY <group by definition> [HAVING <expression> [{<operator> <expression>}…]] [ORD 阅读全文
posted @ 2019-11-28 16:06 wztshine 阅读(241) 评论(0) 推荐(0) 编辑
摘要: MySQL的约束 ※ 主键约束 :primary key ※ 唯一性约束:unique ※ 外键约束:foreign key ※ 非空约束:not null ※ 默认值约束:default 1. 添加主键约束 PRIMARY KEY 1. 直接在字段后添加:PRIMARY KEY <字段名> <数据 阅读全文
posted @ 2019-11-28 15:50 wztshine 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 1. 建表的基本语法 CREATE TABLE <表名> ([表定义选项])[表选项][分区选项]; # 表定义选项的格式:<字段> <type>,<字段> <type>, ... 在当前数据库下创建表 # 切换数据库 mysql> use test_db Database changed # 在当 阅读全文
posted @ 2019-11-28 10:53 wztshine 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 转自:http://c.biancheng.net/view/2425.html MySQL常用的数据类型 1. 数字类型 包括 TINYINT、SMALLINT、MEDIUMINT、INT、BIGINT,浮点数类型 FLOAT 和 DOUBLE,定点数类型 DECIMAL。 2. 时间日期 YEA 阅读全文
posted @ 2019-11-27 16:13 wztshine 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 数据库存储引擎是数据库底层软件组件,数据库管理系统使用数据引擎进行创建、查询、更新和删除数据操作。不同的存储引擎提供不同的存储机制、索引技巧、锁定水平等功能,使用不同的存储引擎还可以获得特定的功能。 查看默认引擎: show variables like 'default_storage_engin 阅读全文
posted @ 2019-11-27 15:48 wztshine 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 一. 创建数据库 [] 代表可选项。 IF NOT EXISTS:在创建数据库之前进行判断,只有该数据库目前尚不存在时才能执行操作。 <数据库名>:创建数据库的名称。MySQL 的数据存储区将以目录方式表示 MySQL 数据库,因此数据库名称必须符合操作系统的文件夹命名规则,注意在 MySQL 中不 阅读全文
posted @ 2019-11-27 14:32 wztshine 阅读(629) 评论(0) 推荐(0) 编辑
摘要: 在相应的用户根目录下生成密钥公钥,输入如下命令: ssh-keygen -t rsa 直接三次回车:会生成两个文件:id_rsa, id_rsa.pub,分别为密钥和公钥 打开公钥 id_rsa.pub 文件,复制里面的内容,并将复制的内容追加到你想要免密登录的服务器的 /root/.ssh/aut 阅读全文
posted @ 2019-11-24 21:32 wztshine 阅读(9142) 评论(0) 推荐(0) 编辑
摘要: 1. 反射 hasattr(obj,'name') # 判断对象中是否含有字符串形式的方法名或属性名,返回True、False getattr(obj,'name',None) # 返回对象中的方法或属性: obj.name,如果没有此方法或属性,返回None setattr(obj,'name', 阅读全文
posted @ 2019-11-16 17:49 wztshine 阅读(320) 评论(0) 推荐(0) 编辑
摘要: 1. try……except a = dict(name = 'wang') b = [1,2,3] try: # 尝试着执行try里面的代码 print(a) print(a['age']) print(b[100]) except (NameError,) as e: # 遇到NameError 阅读全文
posted @ 2019-11-16 17:08 wztshine 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 类变量和实例变量 变量定义在类中,和类中的方法同一级别,就是类变量。 定义在实例中,绑定在 self 上的变量,是实例变量。 class Car(): region = 'China' # 类变量 def __init__(self,brand,price): self.brand = brand 阅读全文
posted @ 2019-11-13 13:16 wztshine 阅读(1326) 评论(0) 推荐(0) 编辑
摘要: 转载自:https://xin053.github.io/2016/07/18/configparser配置文件解析器使用详解/ configparser简介 本文介绍python3中configparser模块的使用,configparser模块是用来解析ini配置文件的解析器,关于ini配置文件 阅读全文
posted @ 2019-11-02 13:08 wztshine 阅读(361) 评论(0) 推荐(0) 编辑
摘要: 常见的匹配字符 1. 匹配模式 ^ 匹配行首 $ 匹配行尾 [] 匹配包含在中括号中的任意字符eg. [abc] [^] 匹配包含在中括号中的字符之外的字符eg. [^0-9] [-] 匹配指定范围的任意单个字符eg.[a-z0-9A-Z] {n,} 配置之前项至少n次 '.' 默认匹配除\n之外的 阅读全文
posted @ 2019-11-02 11:28 wztshine 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 原文链接:https://www.cnblogs.com/zhou2019/p/10582716.html subprocess 是Python 2.4中新增的一个模块,它允许你生成新的进程,连接到它们的 input/output/error 管道,并获取它们的返回(状态)码。这个模块的目的在于替换 阅读全文
posted @ 2019-11-01 22:05 wztshine 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 1. hashlib:MD5,sha256,sha512 import hashlib # ######## md5 ######## hash = hashlib.md5() hash.update('admin'.encode()) print(hash.hexdigest()) # ##### 阅读全文
posted @ 2019-11-01 21:07 wztshine 阅读(258) 评论(0) 推荐(0) 编辑
摘要: import sys import time # 打印消息,类似print,但是不会换行(print实际是调用此方法,只是默认会换行) sys.stdout.write('abcde') sys.stdout.write('fghijk') sys.stdout.write('\rAAAA') # 阅读全文
posted @ 2019-11-01 19:09 wztshine 阅读(160) 评论(0) 推荐(0) 编辑
摘要: import random print(random.random()) # 0< x <1 的浮点数 print(random.uniform(1,5)) # 1<x <5 的浮点数 print(random.randint(1,2)) # 1<= x < =2 的整数 print('jiii', 阅读全文
posted @ 2019-11-01 16:56 wztshine 阅读(229) 评论(0) 推荐(0) 编辑
摘要: import os path = os.getcwd() os.getcwd() #获取当前工作目录,即当前python脚本工作的目录路径 os.chdir(path) #改变当前脚本工作目录 os.curdir #返回当前目录: ('.') os.pardir #获取当前目录的父目录字符串名:(' 阅读全文
posted @ 2019-11-01 16:45 wztshine 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 时间的三种格式: 1)时间戳 2)格式化的时间字符串 3)元组(struct_time):time.struct_time(tm_year=1970, tm_mon=5, tm_mday=23, tm_hour=20, tm_min=7, tm_sec=14, tm_wday=5, tm_yday= 阅读全文
posted @ 2019-11-01 16:35 wztshine 阅读(168) 评论(0) 推荐(0) 编辑