![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
Nonevx
From Zero To Hero
展开
-
Python递归生成树形结构数据
Tree组件数据源构造原创 2022-06-30 10:37:01 · 2315 阅读 · 2 评论 -
解决: Python运行项目中单个文件时报错 ModuleNotFoundError
项目通过pycharm创建和开发, 包含多个层级和目录, 并且要运行的单个python文件引用了其他目录的模块和第三方模块, 原本通过pycharm可以直接运行单个文件, 一切正常, 但是通过命令行的方式通过python命令运行单个文件时, 运行报错, 错误如上…原因分析(未找到’xxxx’模块):...原创 2022-06-07 12:12:25 · 642 阅读 · 1 评论 -
解决: Selenium自动化 Element is not clickable at point 问题
本机环境系统: windows11语言: python 3.9.7框架: selenium==4.1.2前端: vue报错selenium.common.exceptions.ElementClickInterceptedException: Message: Element <div class=“path”> is not clickable at point (1177,96) because another element <span> obscures i原创 2022-04-28 10:39:22 · 2005 阅读 · 5 评论 -
解决: ValueError: source code string cannot contain null bytes 问题
巨坑…根据报错很难看出问题…其实是编码问题…解决办法:使用vscode打开, 修改文件编码为utf-8原创 2021-12-02 15:12:44 · 6356 阅读 · 0 评论 -
Python常用代码: 使用sqlalchemy库操作mysql数据库
复制代码, 保存为.py文件, 在需要使用的模块调用即可(需要手动修改所需连接数据库信息)from sqlalchemy import funcfrom sqlalchemy import create_enginefrom sqlalchemy.orm import sessionmakerclass DbOperation: def __init__(self, db_name): # 创建数据库引擎 self.engine = create_en.原创 2021-09-24 16:04:21 · 356 阅读 · 0 评论 -
Python常用代码: 数据读写(json, txt, html)
复制代码, 保存为.py文件, 在需要使用的模块调用即可(注意文件位置修改), 日志器内容参考上一篇文章, 需要引入的第三方库请自行下载…import osimport jsonfrom bs4 import BeautifulSoupfrom utils.get_log import GetLog# 获取日志器log = GetLog.get_log()def read_json(file_name): """ 读取json文件为python字典对象 :p.原创 2021-08-30 19:09:46 · 359 阅读 · 0 评论 -
Python常用代码: 封装日志器
复制代码, 保存为.py文件, 在需要使用的模块调用即可(需要手动修改日志文件保存位置)import logging.handlersclass GetLog: logger = None @classmethod def get_log(cls): if cls.logger is None: # 获取 日志器 cls.logger = logging.getLogger() # .原创 2021-08-30 18:40:19 · 129 阅读 · 0 评论 -
Pytest接口自动化测试框架搭建模板
auto_api_test开发环境: Pycharm开发语言&版本: python3.7.8测试框架: Pytest、测试报告: Allure项目源码Git地址项目目录结构api – 模仿PO模式, 抽象出页面类, 页面类内包含页面所包含所有接口, 并封装成方法可供其他模块直接调用config – 配置文件目录data – 测试数据目录doc – 文档存放目录log – 日志report – 测试报告scripts – 测试脚本存放原创 2021-01-21 16:47:54 · 2717 阅读 · 1 评论 -
Flask接收带文件表单请求
Python: 3.6.10Flask: 1.1.2目录结构index.pytemplatesindex.htmltest.png前端代码<!DOCTYPE html><html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Upload Example</title> &.原创 2020-11-19 16:38:28 · 1296 阅读 · 2 评论 -
Python远程调用执行Window程序
Windows服务: winrmPython类库: pywinrmA机器远程连接B机器1. 在A机器上需要有Python运行环境, 安装pywinrm模块pip install pywinrm2. 在B机器配置winrm服务, 使其能够开启监听, 接收远程指令# 快速在服务端运行winrm winrm quickconfig # 把服务中的allowUnencrypted设置为true,允许未加密的通讯 winrm set winrm/.原创 2020-11-06 10:16:21 · 1463 阅读 · 0 评论 -
解决: pip安装库缺少vc++依赖的问题
示例库: python-ldap系统: Microsoft Windows [版本 10.0.18363.836]Python版本: Python 3.7.4pip版本: pip 20.1.1常规流程pip安装: pip install python-ldap安装报错, 大概意思就是缺少必须的vc++库, 很多python库安装时都需要依赖vc++库, 但是我们不需要安装vc++库也能解决这个问题, 就是使用.whl 文件安装whl文件下载地址下载最新的amd-64的whl文件, .原创 2020-05-20 11:17:50 · 1776 阅读 · 0 评论 -
Python安装的依赖列表导出到文件和批量安装依赖文件
当更新安装Python时, 卸载之前的安装, 会连带pip之前安装的库文件一同卸载, 可以使用命令导出已安装的库的列表到文件, 等安装完新的Python后, 在通过文件批量安装库文件1.导出安装列表到文件pip freeze > requirements.txt2.通过文件批量安装库文件(使用清华的源)pip install -r requirements.txt -i htt...原创 2019-05-29 14:47:55 · 1865 阅读 · 0 评论 -
Python的冒泡排序算法
冒泡排序相邻元素两两比较, 大的放在后面, 第一次比较完毕后, 最大值就会出现在最大索引处, 以此类推…num_list = [2, 9, 4, 5, 7, 8, 6, 3, 1]def bubble_sort(list_data): for i in range(0, len(list_data)-1): for j in range(0, len(list...原创 2019-06-05 21:10:12 · 300 阅读 · 0 评论 -
Python3的安装和pip包管理器的基本使用
本文环境系统: Windows10Python版本: 3.6安装python安装包下载可以选择安装版和解压版安装版一键安装, 安装过程注意选择安装位置, xx To Path选项(勾选), 和是否安装pip选项(选择安装)解压版需要手动配置环境变量在命令行输入以下命令确认是否安装配置成功$ python -V$ pip -V# 如果正常返回版本号, 则安装...原创 2019-04-20 09:22:26 · 585 阅读 · 0 评论 -
人生苦短, 我用Python之一句话打印'*'图案(列表推导式)
# coding=utf-8 print ('\n'.join(['*'*6 for i in range(4)])) # ****** # ****** # ****** # ****** print ('\n') print ('\n'.join(['*'*(i*...原创 2019-04-19 09:20:13 · 1271 阅读 · 0 评论 -
Python3字符串常用方法与isdigit(), isdecimal(), isnumeric()的区别
# 全部小写string.lower()# 全部大写string.upper()# 是否全部小写string.islower()# 是否全部大写string.isupper()# 首字母大写string.capitalize()# 大小写转换string.swapcase()# 检查字符串是否是以 str 开头string.startswith(str)# 检查字符串是...原创 2019-04-15 13:56:07 · 675 阅读 · 0 评论 -
Python3列表的的深拷贝和浅拷贝
a = 1b = aa = 2print(a, b)print(id(a), id(b))"""运行结果2 11445293568 1445293536"""# 列表直接复赋值给列表不属于拷贝, 只是内存地址的引用list1 = ["a", "b", "c"]list2 = list1list1.append("d")print(list1, list2)print...原创 2019-04-14 14:27:50 · 1585 阅读 · 0 评论 -
Python3列表中获取相同元素所有下标或指定第n次出现的下标
前言list: Python3的列表类型, 和其他语言中的数组类似定义格式: l = ["a", "b", "c", "a", "b", "c", "a"] , 下文举例用到的列表x为此列表list常用方法(文章中用到的方法):index(元素[, Start[, Stop]]) : 获取列表下标三个参数, 后两个参数为可选参数.一个参数, PS: l.index("...原创 2019-04-12 14:42:05 · 9598 阅读 · 2 评论