随笔分类 -  python

摘要:concurrent.futures 异步执行可以由 ThreadPoolExecutor 使用线程或由 ProcessPoolExecutor 使用单独的进程来实现。 两者都是实现抽像类 Executor 定义的接口。 concurrent.futures.Executor 抽象类提供异步执行调用 阅读全文
posted @ 2021-08-05 15:46 wztshine 阅读(152) 评论(0) 推荐(0) 编辑
摘要:安装: pip install matplotlib 入门 简单介绍: 举个例子,在现实中,我们想要画一个图表,首先需要找一个可以画的地方来画,譬如一张纸,一块黑板等,这些承载图像的东西,称之为:figure 然后,你需要画图,以黑板为例子,一个黑板上面可以画多个坐标轴,坐标轴即带有x,y轴 (Ax 阅读全文
posted @ 2021-08-04 22:16 wztshine 阅读(1603) 评论(0) 推荐(0) 编辑
摘要:今天看别人写的代码,看到这么一句话 sys.excepthook = exception_hook 看网上的说法,说是重定向异常的。试验一下 # -*- coding: utf-8 -*- import sys def exception_hook(exctype, value, traceback 阅读全文
posted @ 2021-08-04 17:25 wztshine 阅读(594) 评论(0) 推荐(0) 编辑
摘要:logging模块 日志级别 默认的日志级别是:warning 级别 数值 CRITICAL 50 ERROR 40 WARNING 30 INFO 20 DEBUG 10 NOTSET 0 1. 工作流程 logging的几个组件:记录器(Logger)、处理器(handler)、过滤器(filt 阅读全文
posted @ 2021-07-27 11:27 wztshine 阅读(271) 评论(0) 推荐(0) 编辑
摘要:理解列表切片正负数 先说结论: 列表切片的格式为[start: end: step] 其中 step 代表步长,即每从 start 位置开始每隔几个元素取一个值 step 为正数时表示切片取值方向为:从左往右;为负数时:从右往左 start, end 代表切片取值的起始和结束位置,请注意这个词:位置 阅读全文
posted @ 2021-07-23 13:45 wztshine 阅读(3059) 评论(0) 推荐(0) 编辑
摘要:import pynput start = None end = None def on_click(x, y, button, pressed): global start, end print('{0} {1} at {2}'.format(button,'Pressed' if pressed 阅读全文
posted @ 2021-07-22 13:25 wztshine 阅读(202) 评论(0) 推荐(0) 编辑
摘要:Pathlib Pathlib 有 Path,PurePath 两个常用的模块。Path 是带有 IO 操作的对象,可以使用 Path.exists(),Path.is_file() 等方法。而 PurePath 可以简单理解为字符串,不能进行 IO 的操作。如果你只是单纯的进行路径字符拼接、路径分 阅读全文
posted @ 2021-07-22 10:31 wztshine 阅读(165) 评论(0) 推荐(0) 编辑
摘要:pandas Excel简单的操作 读写excel,csv a.xlsx Title name age Time ti1 wang 23 2021/2/2 22:24 ti2 zhang 33 2021/2/2 22:24 示例: import pandas as pd # 读取excel时,会将第 阅读全文
posted @ 2021-06-22 23:01 wztshine 阅读(633) 评论(0) 推荐(0) 编辑
摘要:本文参考链接: https://learning-pytest.readthedocs.io/zh/latest/ https://blog.csdn.net/qq_42610167/article/details/101204066#8pytesthtml_773 https://qualitys 阅读全文
posted @ 2021-04-11 20:49 wztshine 阅读(362) 评论(0) 推荐(0) 编辑
摘要:直接上实例: 目录结构: - a # 文件夹 - a.py - b.py - config.txt 在 文件夹 a 下有个 a.py,它使用相对路径去读取config.txt的一行数据 def reader(): with open('../config.txt','r') as f: line = 阅读全文
posted @ 2021-03-07 19:24 wztshine 阅读(5017) 评论(0) 推荐(0) 编辑
摘要:# 粗浅理解 ## 基本概念 ### Future Future,故名思意,就是一个在**未来**能**产生结果**的对象。未来,意味着 Future 会阻塞(譬如遇到 IO,或者等待 Future 被其他人设置一个结果,都会阻塞);结果,代表着Future的结束时的最终产物(譬如发生了异常Exce 阅读全文
posted @ 2021-02-28 22:11 wztshine 阅读(1112) 评论(0) 推荐(0) 编辑
摘要:现有两个文件: a.py from inspect import currentframe, stack, getmodule def write(msg): f_current_line = str(currentframe().f_back.f_lineno) # 哪一行调用的此函数 print 阅读全文
posted @ 2021-02-25 16:53 wztshine 阅读(1654) 评论(1) 推荐(0) 编辑
摘要:## 数据描述符,属性查找优先级 **如果在一个类中定义了 `__get__()` , `__set__(),` `__delete__()` 这三种方法之一,那么这个类是一个描述符。** 描述符分成两种: - 如果这种类只定义了 `__get__` 方法,那么就是一个非数据描述符, - 定义了 ` 阅读全文
posted @ 2021-01-24 21:58 wztshine 阅读(306) 评论(0) 推荐(0) 编辑
摘要:from datetime import datetime as DT import time time_stamp = 1605151831 time_stame_array = time.localtime(time_stamp) y = time.strftime("%Y-%m-%d %H:% 阅读全文
posted @ 2020-11-13 10:07 wztshine 阅读(3876) 评论(0) 推荐(0) 编辑
摘要:参考自:https://www.php.cn/python-tutorials-427622.html 安装第三方库 pip install numpy pip install pandas pip install xlrd # 操作excel时会用到 构造数据 DataFrame 第一个参数: ​ 阅读全文
posted @ 2020-11-11 17:47 wztshine 阅读(137) 评论(0) 推荐(0) 编辑
摘要:xpath_test.html <html> <body> <head>xml Test</head> <div id="content"> <ul id="ul"> <li>NO.1</li> <li>NO.2</li> <li>NO.3</li> </ul> <ul id="ul2"> <li> 阅读全文
posted @ 2020-11-08 20:58 wztshine 阅读(202) 评论(0) 推荐(0) 编辑
摘要:下面的文本部分摘抄自:W3school 选取节点 XPath 使用路径表达式在 XML 文档中选取节点。节点是通过沿着路径或者 step 来选取的。 下面列出了最有用的路径表达式: 表达式 描述 nodename 选取此节点的所有子节点。 / 从根节点选取。 // 从当前节点开始选择文档中的任意匹配 阅读全文
posted @ 2020-11-08 16:38 wztshine 阅读(2852) 评论(0) 推荐(0) 编辑
摘要:class Node: """ 节点类 """ def __init__(self, value=None, left=None, right=None): self.val = value self.left = left self.right = right class Tree: """ 树类 阅读全文
posted @ 2020-09-17 21:31 wztshine 阅读(156) 评论(0) 推荐(0) 编辑
摘要:非打印字符 非打印字符也可以是正则表达式的组成部分。下表列出了表示非打印字符的转义序列: 字符 描述 \cx 匹配由x指明的控制字符。例如, \cM 匹配一个 Control-M 或回车符。x 的值必须为 A-Z 或 a-z 之一。否则,将 c 视为一个原义的 'c' 字符。 \f 匹配一个换页符。 阅读全文
posted @ 2020-07-23 14:11 wztshine 阅读(201) 评论(0) 推荐(0) 编辑
摘要:用法:注意是用英文的逗号",",且之间没有空格。 文件名,[工作表名称,不写则默认当前激活的表],[从第几行开始,不写则默认第二行,因为很多表第一行是title],列名(第一列是要查找的元素,列名可以不连续,比如“ade”) 脚本会自动把要查找的第一列进行大小写变换,去除空格等操作,下面的例子中,第 阅读全文
posted @ 2020-06-20 12:11 wztshine 阅读(3755) 评论(0) 推荐(0) 编辑

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