12 2019 档案

摘要:import os def del_none_folder(path): max_len = len(path.split('\\')) for folder,subfolder,file in os.walk(path): # 获取最大路径长度 if len(folder.split('\\')) 阅读全文
posted @ 2019-12-30 11:28 wztshine 阅读(535) 评论(0) 推荐(0) 编辑
摘要:__getattribute__ 、__getattr__ 、__setattr__ 当我们调用 obj.xxx 来访问 obj 的属性时,会自动调用 obj 的 __getattribute__ 方法来返回属性的值。 只有显式的调用 __getattr__,或者当 __getattribute__ 阅读全文
posted @ 2019-12-30 09:42 wztshine 阅读(332) 评论(0) 推荐(0) 编辑
摘要:将基础文件夹下的文件,按照目录结构,同步到目标文件夹下,如果目标文件夹下没有相应的目录结构,就创建目录,然后再将基础文件夹下的文件同步到相应的目录下去。 import os import shutil import time import hashlib # MD5值 def getMD5(path 阅读全文
posted @ 2019-12-29 22:21 wztshine 阅读(1064) 评论(0) 推荐(0) 编辑
摘要:安装模块: pip install pyftpdlib 实例: #-*- coding:utf-8 -*- from pyftpdlib.authorizers import DummyAuthorizer from pyftpdlib.handlers import FTPHandler from 阅读全文
posted @ 2019-12-29 22:12 wztshine 阅读(354) 评论(0) 推荐(0) 编辑
摘要:1. select模块 针对select,要先理解其他几个概念: 文件描述符: 文件描述符在形式上是一个非负整数。实际上,它是一个索引值,指向内核为每一个进程所维护的该进程打开文件的记录表。当程序打开一个现有文件或者创建一个新文件时,内核向进程返回一个文件描述符。 内核空间: Linux简化了分段机 阅读全文
posted @ 2019-12-24 13:40 wztshine 阅读(769) 评论(0) 推荐(0) 编辑
摘要:转自:http://blog.csdn.net/majianfei1023/article/details/45788591 要了解socket可读可写条件,我们先了解几个概念: 1.接收缓存区低水位标记(用于读)和发送缓存区低水位标记(用于写): 每个套接字有一个接收低水位和一个发送低水位。他们由 阅读全文
posted @ 2019-12-23 21:45 wztshine 阅读(1992) 评论(0) 推荐(0) 编辑
摘要:文档地址: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 阅读(547) 评论(0) 推荐(0) 编辑
摘要:套接字(socket)是一个抽象层,应用程序可以通过它发送或接收数据,可对其进行像对文件一样的打开、读写和关闭等操作。 1. 实现客户端发送字符,服务器返回大写的字符: 服务器: import socketserver class MyTCPHandler(socketserver.BaseRequ 阅读全文
posted @ 2019-12-22 12:50 wztshine 阅读(1337) 评论(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 阅读(162) 评论(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 阅读(1651) 评论(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 阅读(350) 评论(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 阅读(380) 评论(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 阅读(131) 评论(0) 推荐(0) 编辑
摘要:Queue 是 python 标准库中的线程安全的队列(FIFO)实现, 提供了一个适用于多线程编程的先进先出的数据结构 队列类型 先入先出、后入先出、优先级队列 # 普通队列,先入先出,maxsize=0意味着队列没有上限 q0 = queue.Queue(maxsize=2) # last in 阅读全文
posted @ 2019-12-02 13:28 wztshine 阅读(1054) 评论(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 阅读(628) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示