自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 elastic search

1. 清空索引数据:http://ip:9200/indexName/type/_delete_by_query?pretty={ "query": { "match_all": { } }}2. 按照关键字删除http://ip:9200/indexName/_delete_by_query{"query": {"match": {"merchantId":"${merchantId}"...

2021-05-17 11:24:38 145

原创 008.姓名生成器

#名字生成器,由于"名.txt"的数据较少,所以有可能会有重复的,放到Excel删除重复项即可,或者将名的数据造多写。import os,randomos.chdir("E:\\04.AutomationProject\\PracticePython\\TestCase")nameFileF = open("百家姓.txt",'r',encoding='gb18030')Fname = n...

2019-02-27 17:02:51 1425

原创 第15章实践项目:超级秒表

#第15章实践项目:超级秒表import timeprint('press ENTER to begin.Afterwards,press ENTER to "click" the stopwatche. Press Ctrl-c to quit')input()print('Started.')startTime = time.time()lastTime = startTime...

2019-02-26 15:57:55 286 1

原创 第14章实践项目:Excel到csv的转换

#第14章实践项目:Excel到csv的转换import openpyxl,os,csvfor excelFile in os.listdir('.\\headerRemoved'): if not excelFile.endswith('.xlsx'): continue print('===Transforming ' + excelFile + ' to...

2019-02-26 11:23:00 216

原创 第14章项目:获取的上海当前天气数据

# 在dos命令下输入:python36 test.py 上海import json, requests, sys# Compute location from command line arguments.# if len(sys.argv) < 2:# print('Usage: quickWeather.py location')# sys.exit()#...

2019-02-21 18:13:02 279

原创 第13章:暴力 PDF 口令破解程序

#第十三章:暴力 PDF 口令破解程序import PyPDF2pwdFile = open('dictionary.txt','r')pwdList=pwdFile.readlines()pdfReader = PyPDF2.PdfFileReader(open('encryptedMinutes.pdf','rb'))pwdDic = []for pwd in pwdList:...

2019-02-19 14:18:58 1312

原创 第13章实践项目:定制邀请函,保存为 Word 文档

#第十三章实践项目:定制邀请函,保存为 Word 文档#可以单独设置字体doc.paragraphs[i].style.font.name = 'Harlow Solid Italic'#docx只能引用word本身存在的样式,以下代码可查询内置可用的样式:'''from docx.enum.style import WD_STYLE_TYPEfrom docx import Docum...

2019-02-19 10:06:40 445

原创 第13章 PDF偏执狂

#第十三章 PDF偏执狂#①使用os.work()函数遍历文件夹下所有pdf文件,存储在fileList[]中#②判断这些pdf是否已经加密,如果没有是,顺次读取这些pdf并用123456加密#③给加密后的pdf以原名称加上_encrypted后缀重命名,保存为新的文件#④读取这些加密后的pdf,并用12345解密,确保加密的正确性#⑤如果口令错误,则输出“密码输入错误,错误文件为:x...

2019-02-18 16:17:48 186

原创 第13章 从多个PDF中合并选择的页面

import os,PyPDF2path = "E:\\04.AutomationProject\\PracticePython\\"pdfWriter = PyPDF2.PdfFileWriter()for currentFolder,subFoders,fileNames in os.walk(path): for fileName in fileNames: ...

2018-08-28 18:05:07 211

原创 第12章 将Excel内容写入文本

import openpyxlfrom openpyxl.utils import get_column_letterwb = openpyxl.load_workbook("style.xlsx")sheets = wb.worksheetsfor st in sheets: fileName = str(st)[12:-2]+".txt" fp = open(file...

2018-08-27 13:48:39 248

原创 第12章 将某目录下所有文本读取到Excel中

import os,reimport openpyxl#读取目录下的所有txt文件wb = openpyxl.Workbook()sheet = wb.activefilePath = 'E:\\04.AutomationProject\\PracticePython\\'pathDir = os.walk(filePath)i=1for root, subFolders, fi...

2018-08-27 10:11:04 185

原创 007.时间戳和正常时间格式间的转换

#python中时间的存储格式: time.struct_time(tm_year=2018, tm_mon=8, tm_mday=16, tm_hour=10, tm_min=13, tm_sec=13, tm_wday=3, tm_yday=228, tm_isdst=0)#时间戳,根据1970年1月1日00:00:00开始按秒计算的偏移量。# time.time() 生成当前的时间戳,...

2018-08-16 10:46:56 279

原创 第12章 电子表格单元格翻转程序

##第十二章 电子表格单元格翻转程序##方法一:import openpyxlfrom openpyxl.utils import get_column_letterwb = openpyxl.load_workbook('style.xlsx')sheet = wb.active# length = sheet.max_row if sheet.max_row > sheet...

2018-08-14 11:21:55 316

原创 第12章 Excel插入空白行

#方法一思路:先复制前N 行的内容写入到新表格;②将N行之后内容行号加上M后,再写入新的电子表格import openpyxlfrom openpyxl.utils import get_column_letterdef blankRowInsert(n,m): wb = openpyxl.load_workbook("style.xlsx")#原始表格 wb2 = ope...

2018-08-13 13:56:54 571 1

原创 第12章项目 乘法表

import openpyxlfrom openpyxl.styles import Font,colorsdef multi(num): wb = openpyxl.Workbook() sheet = wb['Sheet'] FontStyle = Font(name='微软雅黑',size=12,color=colors.RED,bold=True) ...

2018-08-08 17:44:54 118

原创 006.身份证验证码合法校验

def readIdFile():#此函数用于将身份证的前17位和第18位校验位区分开 fp = open("E:\\04.AutomationProject\\PracticePython\\IdVerify.txt") IDLines = fp.readlines() id17col = [] id18col = [] for ID in IDLine...

2018-08-08 10:39:38 278

原创 第12章 更新商品价格表

import openpyxlwb = openpyxl.load_workbook("produceSales.xlsx")sheet = wb['Sheet']product_price = {'Garlic': 3.07, 'Celery': 1.19, 'Lemon': 1.27}for row in range...

2018-08-07 11:23:41 128

原创 第12章 读取人口普查Excel数据

import openpyxl,pprintprint("=====打开Excel=====")wb = openpyxl.load_workbook("censuspopdata.xlsx")sheet = wb['Population by Census Tract']countryData = {}#Todo: fill in countryDate with each coun...

2018-08-06 16:00:29 1584

原创 第11章 链接验证

import requests,bs4,osurl = "http://www.baidu.com"os.makedirs('xkcd',exist_ok=True)res = requests.get(url)res.raise_for_status()resHtml = bs4.BeautifulSoup(res.text,'html.parser')linkUrl = resH...

2018-08-03 17:04:12 254

原创 第11章:2048联系键盘上下左右键

from selenium.webdriver.common.keys import Keysfrom selenium import webdriverdriver = webdriver.Ie()driver.get(' https://gabrielecirulli.github.io/2048/')html = driver.find_element_by_tag_name('h...

2018-08-03 15:37:57 514

原创 第11章 下载xkcd的漫画

#! python3# downloadXkcd.py - Downloads every single XKCD comic.import requests, os, bs4url = 'http://xkcd.com' # starting url下载图片的网址os.makedirs('xkcd', exist_ok=True) # store comics in ./xkcdw...

2018-08-02 17:17:21 311

原创 第11章:获取html内容

#gain the text of <Romeo and juliet>import requests#罗密欧和朱丽叶的下载地址res = requests.get('http://www.gutenberg.org/files/1112//1112.txt')try: res.raise_for_status()#如果下载网页资源成功则,什么也不做,失败则抛出异常...

2018-08-01 10:20:02 218

原创 第11章:循环打开搜索关键字的网页

import requests,sys,webbrowser,bs4print("========searching========")res = requests.get("http://www.baidu.com/s?wd=python")res.raise_for_status() #检查请求是否成功,若成功,什么也不做;若失败,则抛出异常。#todo:retrieve top s...

2018-08-01 09:50:18 181

原创 第10章:调试抛掷硬币

#第10章:调试抛掷硬币import random,logginglogging.basicConfig(level=logging.DEBUG, format=('%(asctime)s--%(levelname)s--%(message)s'))# logging.disable(logging.DEBUG)logging.debug('\n============start of ...

2018-07-24 17:24:02 367

原创 第9章 消除缺失的编号

#python3import os,re,shutilpath = 'E:\\04.AutomationProject\\PracticePython\\noteBasic'os.chdir(path)#找到指定文件夹中所有哦带指定前缀的文件fileNameList = [i for i in os.listdir('.') if i.startswith('spam') and i.e...

2018-07-12 10:38:47 572

原创 第9章 删除不需要的文件

'''编写一个程序, 遍历一个目录树, 查找特别大的文件或文件夹, 比如, 超过100MB 的文件(获取文件大小,os.path.getsize())。将这些文件的绝对路径打印到屏幕上'''import os,send2trashpath = 'E:\\04.AutomationProject'for currentFolder,subFolder,fileNames in os.walk(...

2018-07-09 17:43:32 184

原创 第9章 选择性拷贝

import os,re,shutilpath = 'E:\\04.AutomationProject'fileNameList = os.listdir(path)folder = "E:\\test"if os.path.exists(folder): print("目录存在")else: os.mkdir("E:\\test") print("目录创建成功...

2018-07-09 17:15:32 446

原创 004.文件更名

#pythonn3#renameDatet.py -rename filesnames with American MM-DD-YYYY date format#to European DD-MM-YYYY#shutil.move()可以用于文件改名.正则表达式中,每遇到一个左括号group就累计加1import shutil,os,re#create a regex that mat...

2018-07-09 16:16:08 166

原创 003.备份文件夹zip

#python3 backupToZip()#copies an entire folder and its contents into a zip file whose filename incrementsimport zipfile, os,datetimepath = 'E:\\04.AutomationProject\\PracticePython\\noteBasic'os.c...

2018-07-09 16:14:28 145

转载 002.前端性能优化 -- 从 10 多秒到 1.05 秒

转发自作者:子木 链接:https://segmentfault.com/a/11900000150525451. 压缩 合并对于 前端性能优化 自然要关注 首屏 打开速度,而这个速度,很大因素是花费在网络请求上,那么怎么减少网络请求的时间呢?减少网络请求次数减小文件体积使用 CDN 加速所以 压缩、合并 就是一个解决方案,当然可以用 gulp 、 webpack 、 grunt 等构建工具 压缩...

2018-07-06 17:34:22 373

转载 001.前端优化之雅虎35条军规

转载自作者:咸鱼老弟 链接https://www.cnblogs.com/xianyulaodi/p/5755079.html 新博客地址:https://xianyulaodi.github.io阅读目录 内容部分css部分js部分javascript, css 图片 cookie移动端 服务器回到顶部 内容部分1.尽量减少HTTP请求数  80%的终端用户响应时间都花在了前端上,其中大部分时间...

2018-07-06 10:41:21 127

原创 第9章 创建和添加zip文件

#创建和添加压缩文件import zipfile,os,datetimepath = 'E:\\04.AutomationProject\\PracticePython\\noteBasic'os.chdir(path)#方法一:这种方法会把多层级的目录放入压缩包# fileList = []# for folderName, subFolders, fileNames in os.w...

2018-06-29 16:26:27 162

原创 002.文件压缩

import osimport datetimeimport zipfile #Linux下可以用tarfile,windows用zipfileimport fnmatch#1.定义函数find_spe_file,找到要压缩目录下的所有文件及路径#patterns表示文件类型的连接符号比如.txt的.号,如果不输入,默认值为所有类型#args为存放文件的类型def find_spe_...

2018-06-29 11:16:39 570

原创 001.组织机构代码生成

#!/usr/bin/python#全国组织机构代码由八位数字(或大写拉丁字母)本体代码和一位数字(或大写拉丁字母)校验码组成import randomdef OrgCode(): factorList = [3, 7, 9, 10, 5, 8, 4, 2]#加权因子列表 OrgCode = []#用于存放生成的组织机构代码 sum = 0 for ...

2018-06-28 16:58:14 4733

原创 第9章 文件压缩

#文件压缩import zipfile,osos.chdir('E:\\04.AutomationProject\\PracticePython\\noteBasic')# print(os.listdir())exampleZip = zipfile.ZipFile('example.zip')print(exampleZip.namelist())spamInfo =example...

2018-06-27 11:10:01 87

原创 第9章 文件遍历

import osfor folderName, subFolders, fileNames in os.walk('E:\\04.AutomationProject\\PracticePython'): print('The current folder is ' + folderName) for subFolder in subFolders: print(...

2018-06-27 10:41:39 88

原创 第8章 正则表达式查找文件内容

import os, repath = 'E:\\04.AutomationProject\\PracticePython'folder = os.path.exists(path)if folder: print("目录正确!")else: print("目录不存在!")fileNameList = os.listdir(path)for file in fileNa...

2018-06-26 17:02:12 1568

原创 第8章 疯狂填词

#疯狂填词import retext = 'The ADJECTIVE panda walked to the NOUN and then VERB. A nearby NOUN was unaffected by these events.'repTargetList = re.compile(r'[A-Z]{2,}').findall(text)print(repTargetList)...

2018-06-26 16:38:41 459

原创 第8章 扩展多重剪贴板

#!test.py# -*- coding: utf-8 -*-# mcb.pyw - saves and loads pieces of text to the clipboard# usage: python test.py save <keyword> - saves clipboard to keyword# python test.py <keywo...

2018-06-26 16:21:26 882

原创 002. 获取素数的方法

#取100以内的素数方法一:# import mathn = 100lst = [2]for i in range(3, n): for j in lst:#所有的合数可以转换成素数乘积 if i%j == 0: break else: lst.append(i)print(lst)#取100以内的素数方法二:...

2018-06-22 18:36:16 265

空空如也

空空如也

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

TA关注的人

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