自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(108)
  • 收藏
  • 关注

原创 Centos7开机自动启动shell脚本

1.vi /etc/rc.d/rc.local2.末尾添加sh脚本3.检查脚本和rc.local权限是否可执行4.rebot检查

2021-06-28 13:17:09 297

原创 日志文件清理shell

#!/bin/sh list_alldir(){ for file2 in `ls -a $1` do if [ x"$file2" != x"." -a x"$file2" != x".." ];then if [ -d "$1/$file2" ];then find "$1/$file2" -mtime +1 -name "*.log*" -exec rm -rf {} \;

2021-06-23 13:25:12 171

原创 Django设置DEBUG = False后,访问和静态文件丢失问题

1.访问需要设置允许的ip;# DEBUG = TrueDEBUG = False# *允许所有ALLOWED_HOSTS = ['127.0.0.1']2.静态文件丢失由于DEBUG = False后,静态文件夹的路由丢失了,需要配路由;settings.py:STATIC_URL = '/static/'STATIC_ROOT = 'static'#这个是设置静态文件夹目录的路径# STATICFILES_DIRS = (# os.path.join(BASE_DIR,

2020-08-27 15:11:02 1729 1

原创 Python时间戳和时间格式转换(毫秒)

def getdate1(t="2020-08-27 13:30:28"): '''时间转成时间戳''' t1 = time.strptime(t, '%Y-%m-%d %H:%M:%S') # print(t1) t2= int(time.mktime(t1))*1000 # print(t2) return t2def getdate2(t="1598506228000"): '''时间戳转换为时间''' t1 = float(t)/1

2020-08-27 15:01:53 6478

原创 JsonPath笔记

JsonPath借助JSONPath表达式从JSON中抽取数值,进行断言。表达式 意义$ 表示JSON对象的根节点.property 表示在某个对象的属性[‘property’] 表示在某个对象的属性,.property作用一样,当property包含点号时就得用这种形式[n] 表示一个数组中的下标为n的元素[index1,index2,…] 表示一个数组中的下标为index1,index2,…的元素…property 递归查找所有属性名为property的值,返回一个list通配符,匹

2020-07-28 14:58:15 144

原创 requests请求访问java服务,参数中带null

访问java网站的时候,某些参数会传null,如:传空类型null,对应在python的为None,把请求中的null替换成None即可:

2020-07-28 14:31:00 465

转载 Python-requests查看请求内容

import requestsimport jsonimport logging# These two lines enable debugging at httplib level (requests->urllib3->http.client)# You will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA.# The only thing miss

2020-07-28 14:17:05 4728

原创 dockerfile小结

FROM 指定基础镜像RUN 执行命令RUN <命令>,就像直接在命令行中输入的命令一样。刚才写的 Dockerfile 中的 RUN 指令就是这种格式。例:RUN echo ‘<h1>Hello, Docker!’ > /usr/share/nginx/html/index.htmlexec 格式:RUN [“可执行文件”, “参数1”, “参数2”],这更像是函数调用中的格式。注:在撰写 Dockerfile 的时候,这并不是在写 Shell 脚本,而是在定义每一

2020-07-23 14:46:28 94

原创 Docker基础总结

获取镜像docker pull [选项] [Docker Registry 地址[:端口号]/]仓库名[:标签]Docker 镜像仓库地址:地址的格式一般是 <域名/IP>[:端口号]。默认地址是 Docker Hub。仓库名:如之前所说,这里的仓库名是两段式名称,即 <用户名>/<软件名>。对于 Docker Hub,如果不给出用户名,则默认为 library,也就是官方镜像。列出镜像docker image ls虚悬镜像(dangling image):

2020-07-21 16:50:27 102

原创 Docker安装(ubuntu16.04)

安装更新apt$ sudo apt-get update$ sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ software-properties-common源+gpg密钥:#国内源$ curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -# 官方

2020-07-17 13:52:39 143

转载 Vmware新建虚拟机黑屏

以管理员身份运行cmd,然后输入netsh winsock reset,再重启计算机。

2020-07-15 16:30:30 954

原创 python锁小结

from threading import Threadimport os, timecount = 0def work(): global count temp = count time.sleep(0.1) count = temp + 1 def main(): t = [] for i in range(100): p = Thread(target=work) t.append(p)

2020-07-06 08:45:09 128

转载 python-redis使用

根据菜鸟教程的redis教程写的部分总结import redisr=redis.StrictRedis(host='localhost',port=6379,db=0)r.set('foo','bar')r.get('foo')#redis 取出的结果默认是字节,设定 decode_responses=True 改成字符串。r1 = redis.Redis(host='localhost', port=6379, decode_responses=True)r1.set('name', 'r

2020-06-29 14:18:24 1979

原创 python smtp发邮件

"""封装发送邮件的方法"""import smtplibimport timefrom email.header import Headerfrom email.mime.multipart import MIMEMultipartfrom email.mime.text import MIMETextfrom Common import Logfrom Conf.Config import Configclass SendMail: def __init__(self.

2020-06-28 16:07:50 1171

原创 c++vector和数组互换(兼容c)

vector和数组的互换void printArr(int arr[], int n){ cout << "vector传数组" << endl;}printArr(vec.data(), vec.size());int arr[10] = { 1,2,3,4,5,6,7 }; vector<int> vec2(arr,arr+sizeof(ar...

2020-06-24 17:32:45 942

原创 vs2019 生成包含dll的exe

代码:#include<windows.h>#include<cstdlib>#include<ctime>using namespace std;HWND hwnd = GetForegroundWindow();int main() { int x = GetSystemMetrics(SM_CXSCREEN); int y = ...

2020-06-24 17:31:47 4540 1

转载 Django:centos和ubuntu下redis的安装与使用

Django中文网

2020-06-24 16:45:18 151

原创 pymysql插入测试数据模板

import pymysqlimport socketimport structimport randomip=""user=""pwd=""database=""index=5000time=903139688000def getData(): data1=[] data2=[] data3=[] for i in range(index,index+5000): name="Test%s"%i data1.appe

2020-06-23 10:45:21 145

原创 pymysql总结

下载pip install pymysql连接数据库并执行sqldef executeSql(sql): # 打开数据库连接 db = pymysql.connect(host=ip,port=3306,user=user,password=pwd,db=database,charset='utf8') cursor = db.cursor() try: res=cursor.execute(sql) except Exception as e

2020-06-03 17:35:52 126

原创 Pytest运行脚本小结

run.pyimport sysimport pytestimport osROOT_DIR=os.path.dirname(os.path.abspath(__file__))def main(): print(ROOT_DIR) if ROOT_DIR not in sys.path: sys.path.append(ROOT_DIR) # 执行用例 # args = ['--reruns', '1', '--html=' + './repo

2020-05-27 17:26:34 592

原创 httprunner解析swagger接口生成json文件

主要功能:解析excal表格里面的url,访问swagger生成json文件。主要参考了基于HttpRunner,解析swagger数据,快速生成接口测试框架这篇博文,修改代码符合自己的需求而来。解析swagger类:import os, requestsfrom httprunner import loggerfrom lib.processingJson import write_data, get_jsonfrom lib.urls import urlsimport traceback

2020-05-26 17:30:39 1919 1

原创 pytest parametrize参数化数据

pytest.mark.parametrize装饰器可以实现测试用例参数化@pytest.mark.parametrize("num1,num2", [ ("3+7", 10), ("4+4", 8), # ("9*9", 82), #通过mark.xfail标记为失败运行时跳过

2020-05-09 11:08:24 371

原创 pytest conftest小结

pytest里面默认读取conftest.py里面的配置conftest.py配置需要注意以下点:conftest.py配置脚本名称是固定的,不能改名称conftest.py与运行的用例要在同一个pakage下,并且有init.py文件不需要import导入 conftest.py,pytest用例会自动查找ps:如果module级别的,在py文件中第一个未调用,第二个调用,module会在第二个调用时执行通过yield实现teardown:@pytest.fixture(scope="mod

2020-05-09 10:52:13 731

原创 pytest命令和测试用例规则

测试用例规则:测试文件以test_开头(以_test结尾也可以)测试类以Test开头,并且不能带有 init 方法测试函数以test_开头断言使用基本的assert即可所有的包pakege必须要有__init__.py文件#创建JUnitXML格式文件(可被Jenkins或其他持续集成服务器读取的结果文件)pytest --junitxml=path#创建纯文本机器可读的结果文件,计划在pytest 6.0中删除pytest --resultlog=path#生成html报告pytes

2020-05-09 10:41:20 599

原创 Django中app_name和namespace理解

app_name可以解决不同应用中同名子路径导致的异常跳转namespace可以解决同一个应用同一个子路径导致的异常跳转app_name应用场景:主urls:from django.contrib import adminfrom django.urls import pathfrom django.conf.urls import include,urlfrom django im...

2020-04-30 17:49:17 864

原创 Django常用命令

安装Django: pip install django 指定版本 pip3 install django==2.0新建项目: django-admin.py startproject mysite新建APP : python manage.py startapp blog启动:python manage.py runserver 8080同步或者更改生成 数据库:pytho...

2020-04-22 14:51:12 117

原创 Django数据迁移(sqllite3 > mysql)

步骤:1.当前setting数据库配置为sqlite3,执行python manage.py dumpdata --exclude=contenttypes --exclude=auth.Permission > initial_data.json,生成json格式数据.2.更改当前setting配置为mysql,在数据库创建相应数据,执行python manage.py migr...

2020-04-20 13:37:29 363

原创 Django+mysql配置(将默认的sqllite3换成mysql) mysqlclient 1.3.13 or newer is required; you have 0.9.3.错误解决

1.环境说明项目虚拟环境如下:2.配置mysql1.pip install pymysql 下载最新版本pymysql,也可以指定下载0.9.3的版本2.项目的主setting文件,注释掉DATABASES配置,填写mysql的配置# DATABASES = {# 'default': {# 'ENGINE': 'django.db.backends.sql...

2020-04-17 15:10:17 134

原创 Python-openpyxl小结(含IP和MAC随机生成)

生成随机IP和MAC #MAC: # ":".join(["%02x" % x for x in map(lambda x: random.randint(0, 255), range(6))]) #IP # socket.inet_ntoa(struct.pack('>I', random.randint(1, 0xffffffff)))加载原有exca...

2020-04-14 09:40:12 243

原创 Python apscheduler定时任务简单应用

import datetimeimport timefrom apscheduler.schedulers.blocking import BlockingSchedulerdef func(): now = datetime.datetime.now() ts = now.strftime('%Y-%m-%d %H:%M:%S') print('do func ti...

2020-04-13 17:56:29 275

原创 Python日志等级+内容的查找和下载

def findK(self,name,key): '''寻找key并下载内容行到对应的文件中 name:日志名 key:寻找的登记 ''' print('find started') deal_log = './deal/deal_'+name.split('/')[-1].r...

2020-04-13 17:44:46 85

原创 Python删除文件夹下所有文件和文件夹

def __del_file(self,path): ls = os.listdir(path) for i in ls: c_path = os.path.join(path, i) if os.path.isdir(c_path): self.__del_file(c_pat...

2020-04-13 17:41:40 1926

原创 pyqt5配置环境

环境配置1.pip下载虚拟环境pip下载安装pyqt5和pyqt5-tools。2.配置pycharmFile–Setting–Tools–External Tools中添加QTDesigner和PyUIC。QTDesigner在pyqt5-tools包中,具体路径为venv\Lib\site-packages\pyqt5_tools\Qt\bin\designer.exe,工作目录填$...

2020-04-13 17:40:12 755 1

原创 Python paramiko模块小结

检测连接检测是否连接成功 def isConnect(self): '''连接是否成功''' try: transport = paramiko.Transport((self.IP, self.port)) if (self.pwd == ''): # 加载密钥 ...

2020-04-13 17:20:53 225

原创 wamp网站移植LAMP

以前用php写的一个网站,现在移植到centos;1.首先确定自己的wamp版本,在centos上安装;2.安装环境Apache(Server version: Apache/2.4.6 (CentOS)):#下载Apacheyum install -y httpd#防火墙开启80端口firewall-cmd --permanent --zone=public --add-port...

2020-03-10 17:33:20 219

原创 c++图(邻接矩阵、临界列表实现)

邻接列表:#pragma once#include <list>#include <vector>#include <algorithm>#include "Graph.h"using std::vector;using std::list;using std::find;template <typename T>class gr...

2020-02-13 15:15:16 212

原创 c++hash实现(+ELF算法)

Simple_Hash:#pragma onceclass Simple_Hash{ int* data; int count; int capacity=10000;public: Simple_Hash() { data = new int[capacity](); count = 0; } void insert(int key, int val) { ...

2020-01-22 22:56:54 193

原创 B树(二叉搜索树)实现

头文件:#pragma once#ifndef BST_H#define BST_Hnamespace CPP { template<typename K, typename V> class TreeNode { public: K key; V val; TreeNode* left; TreeNode* right; TreeNode(K k...

2020-01-21 23:09:16 86

原创 二叉堆实现(堆排序、 数据结构和算法的动态演示网站推荐)

数据结构和算法的动态演示:https://visualgo.net/zhheap.h:#pragma once#include <vector>#include <iostream>#include <queue>using namespace std;template<typename T>class Heap{ vector&...

2020-01-20 20:38:39 162

原创 selenium-ide+unittest+pytesseract实现验证码识别登录测试

目录结构:1.通过selenium-ide录制流程导出python代码把代码放入test_one.py里,在加上写的验证码识别模块(上一篇博文里)test_one.py代码:# Generated by Selenium IDEimport pytestimport timeimport jsonfrom selenium import webdriverfrom seleni...

2020-01-19 15:36:41 775

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除