JAVA、Python、Go
语言基础
一碗烈酒
这个作者很懒,什么都没留下…
展开
-
Python 进程 消息队列Queue
from multiprocessing import Process, Queuemax = 3q = Queue(maxsize=max)print(q.empty()) # 队列是否为空print(q.full()) # 队列书否已满peple = ["a", 'b', 'c', 'd', 'e', 'f', 'g']for i in peple: if q.full(): print("队列已满") data = q.get() #...原创 2021-09-08 17:48:20 · 625 阅读 · 0 评论 -
APP UI 自动化测试 H5页面元素定位
使用 uc-devtools 代替 uiautomatorviewer 查找定位H5元素由于uiautomatorviewer 只能定位APP原生页面;所以要定位app H5 页面内的元素 使用 uc-devtools 工具要调试的Android 设备上已安装UC浏览器(Android 开发者版):下载地址。安装成功如如显示:usb链接调试手机并打开要调试定位的H5 webview 页面然后在chrome浏览器内 输入chrome://inspect/浏览器内出现H5页面后.原创 2021-08-31 14:32:17 · 1490 阅读 · 1 评论 -
Python threading with自动加锁解锁
import threadingfrom threading import Lockimport time"""使用以下加锁方式with 锁对象: do something 和以下方式一样的效果lock.acquire()try: do somethingfinnaly: lock.release()"""# 此方法加锁,正常执行def demo_one(): time.sleep(1) with lock: .原创 2021-09-08 17:28:02 · 613 阅读 · 0 评论 -
Python 进程 manager进程管理器
"""使用Manager进程管理器 进行进程间的数据共享支持类型 list, dict, Namespace, Lock, RLock, Semaphore, BoundedSemaphore, Condition, Event, Barrier, Queue, Value, Array"""from multiprocessing import Process, Manager, Lockdef work(loc, data): with loc: data['co.原创 2021-09-08 17:52:38 · 904 阅读 · 0 评论 -
Python log日志
直接上代码# 生动态成日志import logging.handlersimport loggingclass GetLog: def __init__(self, log_path): self.log_path = log_path self.logger = None def log(self): if self.logger is None: self.logger = logging.getL原创 2021-02-18 12:09:07 · 1980 阅读 · 1 评论 -
python threading 线程状态
import threadingfrom time import sleepdef demo_func_one(): sleep(1) print("demo one")def demo_func_two(): for i in range(5): sleep(1) print("demo two") print("当前线程: ", threading.current_thread()) # <Thread(Th.原创 2021-09-08 17:24:14 · 3646 阅读 · 0 评论 -
python apscheduler 定时任务
目录简介:APScheduler具有四种组件:调度器:触发器add_job():interval 固定时间间隔触发add_job(): cron 指定时间间隔触发add_job():date 指定时间仅运行一次简介:官网地址:https://apscheduler.readthedocs.io/en/latest/APScheduler具有四种组件: 触发器triggers 作业job stores 执行器executors ...原创 2021-02-28 21:54:15 · 1202 阅读 · 0 评论 -
Python 进程 消息JoinableQueue
"""JoinableQueue 消息类必须在消息队列内的任务被消费(get)时,使用 task_down() 方法 发送被消费信号"""from multiprocessing import Process, JoinableQueueimport timeimport osdef inputQ(queue, name): """加入队列""" queue.put(name + str(os.getpid()) + " -- " + str(time.time())) .原创 2021-09-08 17:53:19 · 314 阅读 · 0 评论 -
Python 进程 multiprocess
访问官网进程介绍:每启动一个进程都是占用独立的内存空间的;每个进程内的数据是独立的;"""简单入门"""import timeimport osfrom multiprocessing import Processdef demo_one(): print("start") time.sleep(10) print(os.getpid(), os.getppid()) # 子进程和父进程的pid print("end")if __na原创 2021-10-12 11:09:36 · 4069 阅读 · 1 评论 -
pycharm 修改运行解释器
原创 2021-07-05 13:03:27 · 250 阅读 · 0 评论 -
Pytest官方文档学习笔记
pytest测试发现的约定: 如果未指定参数,则集合从testpaths(如果已配置)或当前目录开始。或者,命令行参数可用于目录、文件名或节点 ID 的任意组合。 递归到目录中,除非它们匹配norecursedirs. 在这些目录中,搜索test_*.py或*_test.py文件,按其测试包名称导入。 从这些文件中,收集测试项目: test类外的前缀测试函数或方法 test前缀测试Test类中的前缀测试函数或方法(没有__init__方法)..原创 2021-07-03 14:06:03 · 2331 阅读 · 0 评论 -
Python 进程 helloworld
"""进程https://docs.python.org/3/library/multiprocessing.html#multiprocessing.SimpleQueue"""import timeimport osfrom multiprocessing import Processdef demo_one(): print("start") time.sleep(10) print(os.getpid(), os.getppid()) # 子进程和父进程.原创 2021-09-08 17:42:11 · 72 阅读 · 0 评论 -
python pdf文件处理
fpdf简介fpdffpdf 的 github地址fpdf 是从 PHP 的 FPDF 移植而来的,与其他 PDF 库相比,fpdf 简单、小巧、用途广泛,功能先进,易于学习、扩展和维护。特征Python 2.5 到 3.4 支持Unicode (UTF-8) TrueType 字体子集嵌入条码 I2of5 和 code39,二维码即将推出…PNG、GIF 和 JPG 支持(包括透明度和 Alpha 通道)带有视觉设计师和基本 html2pdf 的模板异常支持、其他小修复、改进和 P原创 2022-06-03 17:30:08 · 1392 阅读 · 1 评论 -
python APP UI自动化测试 基本使用
APP自动化测试 +,环境安装 升级:pip install -U selenium +,yaml数据写入、读取方法封装: import yaml #读取数据 def analyze_data(file_name, case_key): with open("../data/" + file_name + ".yaml", "r") as f: dat...原创 2021-02-12 17:26:06 · 319 阅读 · 0 评论 -
python flask简单使用
Flask简介:官网地址:https://dormousehole.readthedocs.io/en/latest/一个基于python的简单轻便的web应用框架。前端实用jinjia2模板引擎。使用:安装:pip install Flask调试运行:python -m 执行文件; 后台运行:nohup python -m 执行文件 日志文件名.log2>&1 &最简单构建例子from flask import Flaskapp = ...原创 2021-02-18 12:05:59 · 3462 阅读 · 0 评论 -
python icecream代替print
icecream 官网 pypi.org安装:pip install icecream使用:ic.disable() # 禁用,只需要禁用就可以直接线上使用,不必要注释,方便的要命# -*- coding:utf-8 -*-from icecream import icic.disable() # 禁用,只需要禁用就可以直接线上使用,不必要注释ic.enable() # 开启# 配置开头prefix; includeContext默认为False,开启后...原创 2021-07-05 11:58:26 · 135 阅读 · 0 评论 -
Python 进程池 回调函数
"""进程池 回调函数 回调函数会把任务函数的结果作为参数执行"""from multiprocessing import Poolimport timeimport osdef work(): time.sleep(1) print("%d 进程 work" % os.getpid()) return time.time()def call(res): # time.sleep(1) print("处理回调结果:{}".format(str(re.原创 2021-09-08 17:52:00 · 478 阅读 · 0 评论 -
Python 使用Click自定义命令行参数
安装:pip install click使用:@click.command()@click.option("--num", default=1, prompt="input run nums:", help="print times")@click.option("--name", default="None", prompt="input your name:", help="name")def demos(num, name): for i in range(num):原创 2021-11-20 12:33:21 · 3583 阅读 · 1 评论 -
python locust 基本使用
Locust简介:官网地址:https://www.locust.io/Locust是易于使用,可编写脚本且可扩展的性能测试工具。特征 用普通的Python编写用户测试方案 如果要让用户循环,执行某些条件行为或进行一些计算,则只需使用Python提供的常规编程结构即可。Locust在其自己的greenlet(轻量级进程/协程)中运行每个用户。这使您可以像编写普通(阻塞)Python代码一样编写测试,而不必使用回调或其他某种机制。因为您的场景是“仅是python”,所以您可以使用常规原创 2021-02-17 19:49:32 · 991 阅读 · 0 评论 -
python 类 方法 函数 机制
闭包注意:如果在内部函数中访问了外层函数内的变量,那么这个变量在函数结束后不会被销毁,会一直在内存中。# 闭包:内部函数调用外部函数的变量def demo_finction_doc(): """ this is the function's doc :return: """ func_name = "1" def get_func_name(): # 检测闭包。 print(get_func_name.__clos原创 2021-09-08 16:46:40 · 126 阅读 · 0 评论 -
python redis 使用
python redis使用一、redis连接使用连接池连接redis数据库。redis连接默认返回的是二进制格式,所以参数添加decode_response=True 返回字符串格式import redispool = redis.ConnectionPool(host='localhost', port=6379, decode_responses=True)r = redis.Redis(host='localhost', port=6379, decode_responses=原创 2021-02-13 18:16:19 · 120 阅读 · 0 评论 -
Python 进程锁
"""每一个进程都有自己独立的空间,多进程操作同一块数据时,必须加锁处理,否则会导致数据错误加锁会把程序变成串行,效率变低"""from multiprocessing import Process, Lockimport timeimport osdef demo_one(): """查票""" with open("data.txt", "r") as f: num = int(f.read()) return numdef demo_t.原创 2021-09-08 17:48:59 · 240 阅读 · 0 评论 -
App UI 自动化测试 定位 toast
目录第一步:安装第二步:启动driver配置uiautomator2第三步:定位目前 uiautomatorviewer 是无法定位toast 的,所有要安装 uiautomator2 来定位 toast第一步:安装# 安装方式一:pip install uiautomator2# 安装方式二:cnpm installappium-uiautomator2-driver第二步:启动driver配置uiautomator2self.desired_caps = ..原创 2021-08-31 16:28:06 · 337 阅读 · 0 评论 -
APP UI自动化测试 H5页面元素定位 chromedriver问题
官网对于appium支持chromedriver的文档:https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/web/chromedriver.md启动appium时 开启自动下载chromedriver命令:appium --allow-insecure chromedriver_autodownloaddesired_caps添加如下appium文件夹位置"chromeOption原创 2021-08-31 16:51:34 · 436 阅读 · 0 评论 -
python加密解密方法
base64解密 def get_base64(str_to_base64): # base64解密 return base64.b64decode(str_to_base64)MD5加密 def get_md5(str): # md5加密 return hashlib.md5(str.encode()).hexdigest()...原创 2019-12-29 18:16:54 · 13951 阅读 · 3 评论 -
python接口自动化测试 unittest框架官网学习
接口自动化: +, 接口session使用,关联 import unittest import warnings import requests class TestShop(unittest.TestCase): def setUp(self): # 初始化实例化session对象 ...原创 2021-02-12 17:24:08 · 363 阅读 · 0 评论 -
Python 打包工具 pyinstaller
介绍官网PyInstaller将 Python 应用程序及其所有依赖项捆绑到一个包中。用户无需安装 Python 解释器或任何模块即可运行打包的应用程序。PyInstaller支持 Python 3.6 或更新版本PyInstaller 完全兼容 Windows、Mac OS X 和 GNU/Linux 。并且使用都是一致的。安装pyinstaller 在各平台安装方式是一样的pip install pyinstaller使用使用 pyinstaller 打包后 会在.转载 2021-10-15 18:02:23 · 6746 阅读 · 1 评论 -
python mysql数据库操作
目录一、直连数据库二、使用连接池三、使用ssh链接一、直连数据库# _*_coding:utf-8_*_import pymysqlclass LocalhostMysql: def __init__(self, host, port, user, pwd, *args, **kwargs): # 本地 self.host = host self.port = port self.user = use.原创 2021-03-17 23:03:00 · 206 阅读 · 0 评论 -
Python threading 线程池
from concurrent.futures import ThreadPoolExecutorfrom concurrent import futuresimport timeimport random"""线程死锁 """# def wait_on_future():# f = executor.submit(pow, 5, 2)# # This will never complete because there is only one worker thread .原创 2021-09-08 17:28:42 · 576 阅读 · 0 评论 -
Python Selenium Web自动化框架 官网学习笔记
+环境搭建 1,python3.6+pycharm 2,selenium(2.xx/3.xx版本) pip install selenium==2.48.0 pip list pip show selenium pip uninstall selenium 3,安装浏览器驱动(浏览器版本对应selenium版本) 1,Firefox...原创 2021-06-29 17:48:00 · 1537 阅读 · 0 评论 -
Python 进程 多进程传参
import timeimport osfrom multiprocessing import Processdef demo_one(num): print("start" + str(num)) time.sleep(1) print(os.getpid(), os.getppid(), num) # 子进程和父进程的pid print("end" + str(num))if __name__ == '__main__': p_list = [.原创 2021-09-08 17:44:15 · 1534 阅读 · 0 评论 -
python web自动化测试命令-笔记
环境搭建 1,python3.6+pycharm 2,selnium(2.xx/3.xx版本) pip install selenium==2.48.0 pip list pip show selenium pip uninstall selenium 3,安装浏览器驱动(浏览器版本对应selenium版本) 1,Firefox48版本以上需...原创 2021-02-12 17:22:11 · 352 阅读 · 0 评论 -
allure 报告
一、简介二、下载安装三、报告生成四、环境配置五、Python 使用 allure 方法一、简介官方文档:https://docs.qameta.io/allure/二、下载安装1、linux 下载安装先检查是否安装npm: which npm 未安装npm的话:curl--silent --location https://rpm.nodesource.com/setup_10.x | bash - 安装:yum install -y nodejs ...原创 2021-02-20 18:56:36 · 939 阅读 · 0 评论 -
Python http.server 静态文件服务器
Python3 内置模块帮助信息> python -m http.server --helpusage: server.py [-h] [--cgi] [--bind ADDRESS] [--directory DIRECTORY] [port]positional arguments: port 指定访问端口,默认 8000optional arguments: -h, --help 显示帮助信息并退出原创 2021-11-20 12:14:42 · 2008 阅读 · 0 评论 -
Python自动化测试中的参数化使用
ddt安装pip install ddt使用在测试类上添加装饰器 @ddt.ddt ;然后在测试方法(用例)上添加装饰器 @ddt.data(args);还可以使用 @ddt.unpack 对传入的参数进行解包.from ddt import data, ddt, unpackimport unittestimport inspectimport os import sys@ddt # 首先装饰类class TestOneClass(unittest.TestCase):原创 2022-02-25 15:39:05 · 2440 阅读 · 0 评论 -
Django 日志
# settings.py# 日志配置LOGS_DIR = BASE_DIR + "/logs"# logs文件夹不存在时创建文件夹if not os.path.exists(LOGS_DIR): os.mkdir(LOGS_DIR)LOGGING = { 'version': 1, 'disable_existing_loggers': False, # 格式器 'formatters': { 'standard': { .原创 2021-06-04 00:44:43 · 60 阅读 · 0 评论 -
Django Url路由
from django.urls import pathfrom . import viewsurlpatterns = [ path('articles/2003/', views.special_case_2003), path('articles/<int:year>/', views.year_archive), path('articles/<int:year>/<int:month>/', views.month_archiv.原创 2021-05-19 23:53:13 · 205 阅读 · 0 评论 -
python 异步 请求接口
import asyncioimport aiohttpimport timeasync def fetch(session, url): print("发送请求", url) async with session.get(url, verify_ssl=False) as response: content = await response.content.read() with open(file=str(time.time()) + ".jp.原创 2021-09-08 17:56:05 · 1457 阅读 · 0 评论 -
Python 进程 进程池 阻塞
"""进程池Pool.apply() 同步任务方法"""import osimport timefrom multiprocessing import Pooldef work(n): print('%s run' % os.getpid()) time.sleep(1) return n ** 2if __name__ == '__main__': p = Pool(3) # 进程池中从无到有创建三个进程,以后一直是这三个进程在执行任务 res.原创 2021-09-08 17:50:21 · 449 阅读 · 0 评论 -
APP Appium框架官网学习笔记
安卓8以后的手机使用 无法直接截屏,可以使用以下adb命令生成文件。然后运行uiautomatorviewer.bat, 导入pull下来的文件即可# 生成当前手机页面的uix文件到手机adb shell uiautomator dump /sdcard/app.uix# 将手机内的uix文件pull到电脑指定位置adb pull /sdcard/app.uix F:/app.uix# 截取手机当前屏幕图片adb shell screencap -p /sdcard/app.png..原创 2021-07-05 18:03:14 · 847 阅读 · 0 评论