随笔分类 -  Python

摘要:Pandas 用于数据处理 https://pandas.pydata.org/docs/ Matplotlib 用于创建图表 https://matplotlib.org/ # 安装 pip install pandas matplotlib # 导入 import pandas as pd im 阅读全文
posted @ 2024-08-23 16:40 rustling 阅读(23) 评论(0) 推荐(0) 编辑
摘要:动态规划-Python 动态规划(Dynamic Programming,简称DP)是解决多阶段决策过程最优化问题的一种方法。 动态规划算法的基本思想是: 将待求解的问题分解成若干个相互联系的子问题,先求解子问题,然后从这些子问题的解得到原问题的解; 对于重复出现的子问题,只在第一次遇到的时候对它进 阅读全文
posted @ 2024-08-06 20:44 rustling 阅读(80) 评论(0) 推荐(0) 编辑
摘要:回溯算法 回溯算法是一种系统的搜索算法,用于解决诸如排列组合、子集生成、图的路径、棋盘问题等问题。其核心思想是通过递归尝试各种可能的解决方案,遇到不满足条件的解时则回退(回溯),继续尝试其他可能性,直到找到所有的解决方案或确认无解。 主要步骤: 选择路径: 在当前步骤选择一个可能的路径。 递归探索: 阅读全文
posted @ 2024-08-05 23:11 rustling 阅读(120) 评论(0) 推荐(0) 编辑
摘要:基础算法笔记-Python 整理自B站视频 https://www.bilibili.com/video/BV1uA411N7c5 递归 1. 汉诺塔问题 # n个圆盘,从a经过b移动到c def hanoi(n, a, b, c): if n > 0: # 将n-1个圆盘从a经过c移动到b han 阅读全文
posted @ 2024-08-04 22:35 rustling 阅读(19) 评论(0) 推荐(0) 编辑
摘要:FastAPI是一个现代、快速(高性能)的web框架,用于构建API。 官网: https://fastapi.tiangolo.com/ 源码: https://github.com/fastapi/fastapi 安装 # 安装 FastAPI pip install fastapi # 安装 阅读全文
posted @ 2024-08-03 10:39 rustling 阅读(38) 评论(0) 推荐(0) 编辑
摘要:1.生成或获取SSL证书 使用openssl生成自签名证书 # req -x509 生成自签名证书 # -newkey rsa:4096 生成一个新的私钥,指定为4096位的RSA密钥对 # -keyout key.pem 私钥保存到key.pem文件 # -out cert.pem 自签名证书保存 阅读全文
posted @ 2024-07-27 09:49 rustling 阅读(365) 评论(0) 推荐(0) 编辑
摘要:Robot Framework 是一个基于Python的通用自动化测试框架,采用关键字驱动测试(Keyword-Driven Testing)方法。 官网: https://robotframework.org/ 安装Robot Framework pip install robotframewor 阅读全文
posted @ 2024-07-21 22:25 rustling 阅读(108) 评论(0) 推荐(0) 编辑
摘要:Python自动化测试框架-pytest 源码: https://github.com/pytest-dev/pytest 文档: https://docs.pytest.org/en/8.2.x/ 安装: pip install pytest 查看版本: pytest -V 简单样例 # cont 阅读全文
posted @ 2024-06-15 23:23 rustling 阅读(25) 评论(0) 推荐(0) 编辑
摘要:官网 https://www.selenium.dev/ 准备测试环境 使用selenium需要 python3 + selenium + chrome 前提条件 Python3已安装 谷歌浏览器已安装 安装步骤 安装selenium pip install selenium 安装 chrome d 阅读全文
posted @ 2024-04-01 23:18 rustling 阅读(68) 评论(0) 推荐(0) 编辑
摘要:MiniConda安装及使用 Miniconda 是一个 Anaconda 的轻量级替代,默认只包含了 python 和 conda,但是可以通过 pip 和 conda 来安装所需要的包。 官方文档: https://docs.conda.io/en/latest/miniconda.html 安 阅读全文
posted @ 2023-05-14 11:12 rustling 阅读(348) 评论(0) 推荐(0) 编辑
摘要:unittest 是 Python 自带的一个单元测试框架。 快速上手 # 被测代码 def add_func(a, b): return a + b # 测试代码 import unittest class MyTest(unittest.TestCase): def test_add_func( 阅读全文
posted @ 2023-03-19 10:31 rustling 阅读(41) 评论(0) 推荐(0) 编辑
摘要:多进程: 适合处理CPU密集型任务,利用多核处理器并行计算。 多线程: 适合IO密集型任务,因为线程可以在等待IO完成时释放GIL(全局解释器锁),允许其他线程运行。 协程: 适合处理大量并发的IO密集型任务,相比于传统的线程切换,协程切换的开销更小。 多进程 不使用多进程,统计耗时 import 阅读全文
posted @ 2023-02-18 23:00 rustling 阅读(25) 评论(0) 推荐(0) 编辑
摘要:有时需要将电脑上的文件传输到同WiFi下的手机上,可以使用python启动HTTP服务来快速访问 # python2 python -m SimpleHTTPServer # python3 默认端口 8000 python -m http.server # 指定IP和端口 python3 -m h 阅读全文
posted @ 2023-01-01 23:54 rustling 阅读(82) 评论(0) 推荐(0) 编辑
摘要:简介 pywinauto是python在windows环境下自动化操作图形应用的第三方库。支持鼠标和键盘操作,获取文本数据等。 github地址: https://github.com/pywinauto/pywinauto 官方说明文档: https://pywinauto.readthedocs 阅读全文
posted @ 2022-10-22 23:22 rustling 阅读(770) 评论(0) 推荐(0) 编辑
摘要:正则表达式(regular expression)是一种强大的字符串匹配工具。可通过使用特定的字符模式进行搜索、替换等操作。 1. 匹配模式 \d # 数字: [0-9] \D # 非数字: [^\d] \s # 空白字符: [<空格>\t\r\n\f\v] \S # 非空白字符: [^ls] \w 阅读全文
posted @ 2019-11-20 23:26 rustling 阅读(149) 评论(0) 推荐(0) 编辑
摘要:pip安装 # Ubuntu python3 sudo apt install python3-pip # Windows 升级pip python -m pip install -U pip 常用命令 # 库的安装与卸载 pip install requests pip uninstall req 阅读全文
posted @ 2019-11-19 22:13 rustling 阅读(139) 评论(0) 推荐(0) 编辑
摘要:官网文档: https://docs.python.org/3/ 基础语法 1. 注释 #!/usr/bin/env python3 # -*- coding: UTF-8 -*- # Python 3 源码文件默认以 UTF-8 编码 """多行注释""" # 单引号和双引号没有区别 2. 常用数 阅读全文
posted @ 2019-11-19 22:11 rustling 阅读(186) 评论(0) 推荐(0) 编辑

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