随笔分类 -  python基础

python基础
python3--进程,线程,协程效率对比
摘要:python3--进程,线程,协程效率对比 2018-08-02阅读 2710 需求:写一个脚本,判断192.168.11.0/24网络里,当前在线ip有哪些? 知识点: 1 使用subprocess模块,来调用系统命令,执行ping 192.168.11.xxx 命令 2 调用系统命令执行ping 阅读全文
posted @ 2020-07-30 13:21 芦苇草鱼 阅读(357) 评论(0) 推荐(0)
python同时继承多个类且方法相同
摘要:class A(object): def getName(self): print("name is A") class B(object): def getName(self): print("name is B") class C(A, B): def __init__(self): print 阅读全文
posted @ 2019-11-06 13:56 芦苇草鱼 阅读(3822) 评论(0) 推荐(0)
python中单下划线和双下划线
摘要:# test1.pyclass Student(object): def __init__(self): self.__name = "" self.__age = "" self.hobby = "" def _set_age(self): self.__age = 23 print(self._ 阅读全文
posted @ 2019-11-06 09:30 芦苇草鱼 阅读(141) 评论(0) 推荐(0)
python压缩解压文件
摘要:1、源文件 2、压缩文件 3、解压文件 阅读全文
posted @ 2019-09-04 09:53 芦苇草鱼 阅读(327) 评论(0) 推荐(0)
python图像处理
摘要:1、图片尺寸修改from PIL import Imagedef resizeImage(image_in, image_out): """ 修改jpg 图片尺寸到 200kb 左右 """ width = 1600 img = Image.open(image_in) w, h = img.siz 阅读全文
posted @ 2019-08-26 11:23 芦苇草鱼 阅读(323) 评论(0) 推荐(0)
python删除文件或者目录
摘要:import os #os.walk遍历目录后,删除文件和目录def rmDirAndFile(path): #先把各个目录的文件删除完 for root, dirs, files in os.walk(path): for file in files: filepath = os.path.joi 阅读全文
posted @ 2019-08-19 11:58 芦苇草鱼 阅读(1836) 评论(0) 推荐(0)
python循环执行程序的装饰器
摘要:1、从一个页面切换到另外一个页面时,里面点击控件会报控件找不到的错误,需要循环点击直到成功的那次才算完成; 阅读全文
posted @ 2019-08-19 11:16 芦苇草鱼 阅读(651) 评论(0) 推荐(0)
python中logging模块的使用
摘要:import osimport loggingimport timeimport tracebackimport re#os.listdir删除文件def rmFile(path): files = os.listdir(path) for file in files: file_path = os 阅读全文
posted @ 2019-08-19 10:45 芦苇草鱼 阅读(274) 评论(0) 推荐(0)
python中yield迭代器
摘要:excel数据有上千条,最好不要一次性全部读出来放在列表会消耗内存,需要每读一条用yield返回一条;当运行到yield '';的时候,程序暂停了,不会往下继续执行, class SDMS(object): def cpyExcel(self, path): if os.path.isfile(pa 阅读全文
posted @ 2019-08-19 10:41 芦苇草鱼 阅读(302) 评论(0) 推荐(0)
python计算程序执行时间的装饰器使用
摘要:1、经常被问程序执行了多久,每个函数都去写很麻烦,所以打算写个装饰器自动计算程序执行时间;推荐文档,大多数基础题都有: https://python3-cookbook.readthedocs.io/zh_CN/latest/ import timedef clock(func): def cloc 阅读全文
posted @ 2019-08-19 10:25 芦苇草鱼 阅读(1407) 评论(0) 推荐(0)