python处理excel文件可以使用openpyxl库。1.创建和保存excel文件,查看工作表标题:>>>importopenpyxl#引用openpyxl库>>>mywb=openpyxl.Workbook()#此时只创建一个工作表>>>mywb.get_sheet_names()#.get_sheet_names()为弃用的函数,警告Warning(fromwarningsmodule):File"__main__",line1Deprecatio
系统 2019-09-27 17:49:15 2852
此篇是我的《树莓派Python编程入门与实战》的阅读笔记.举例:defcheck():"""检查超平面是否已将样本正确分类:return:true如果已正确分类则返回True"""flag=Falseforitemintraining_set:ifcal(item)<=0:#如果有分类错误的flag=True#将flag设为Trueupdate(item)#用误分类点更新参数ifnotflag:#如果没有分类错误的点了print("最终结果:w:"+str
系统 2019-09-27 17:47:33 2852
ExamplecodeforusingtheSelenium2Pythonbindings.—Gist#ToinstallthePythonclientlibrary:#pipinstall-Uselenium#ImporttheSelenium2namespace(aka"webdriver")fromseleniumimportwebdriver#iPhonedriver=webdriver.Remote(browser_name="iphone",c
系统 2019-08-12 01:32:52 2852
unittest单元测试框架不仅可以适用于单元测试,还可以适用WEB自动化测试用例的开发与执行,该测试框架可组织执行测试用例,并且提供了丰富的断言方法,判断测试用例是否通过,最终生成测试结果。有关python和unittest的基础知识部分就不细说了,大家可自行百度进行深入了解哦,以下是整个unittest四个比较重要的概念。testfixturetestcasetestsuitetestrunnertestfixture:简单来说就是做一些测试过程中需要
系统 2019-09-27 17:57:37 2851
通过窗口标题获取句柄importwin32guihld=win32gui.FindWindow(None,u"AdobeAcrobat")#返回窗口标题为AdobeAcrobat的句柄通过父窗口句柄获取子句柄#parent为父窗口句柄iddefget_child_windows(parent):'''获得parent的所有子窗口句柄返回子窗口句柄列表'''ifnotparent:returnhwndChildList=[]win32gui.EnumChil
系统 2019-09-27 17:47:16 2848
基本映射映射使用在根据不同URLs请求来产生相对应的返回内容.Bottle使用route()修饰器来实现映射.frombottleimportroute,run@route('/hello')defhello():return"HelloWorld!"run()#ThisstartstheHTTPserver运行这个程序,访问http://localhost:8080/hello将会在浏览器里看到"HelloWorld!".GET,POST,HEAD,..
系统 2019-09-27 17:38:14 2848
如下所示:#-*-coding:utf-8-*-importpandasaspdimportnumpyasnpfrompatsy.highlevelimportdmatrices#2.7里面是frompatsyimportdmatricesfromstatsmodels.stats.outliers_influenceimportvariance_inflation_factorimportstatsmodels.apiassmimportscipy.st
系统 2019-09-27 17:57:08 2847
OpenCV函数原型:cv2.resize(InputArraysrc,OutputArraydst,Size,fx,fy,interpolation)参数解释:InputArraysrc输入图片OutputArraydst输出图片Size输出图片尺寸fx,fy沿x轴,y轴的缩放系数interpolation插入方式interpolation选项所用的插值方法:INTER_NEAREST最近邻插值INTER_LINEAR双线性插值(默认设置)INTER_A
系统 2019-09-27 17:54:08 2847
使用pythonopencv返回点集cnt的最小外接矩形,所用函数为cv2.minAreaRect(cnt),cnt是点集数组或向量(里面存放的是点的坐标),并且这个点集不定个数。举例说明:画一个任意四边形(任意多边形都可以)的最小外接矩形,那么点集cnt存放的就是该四边形的4个顶点坐标(点集里面有4个点)cnt=np.array([[x1,y1],[x2,y2],[x3,y3],[x4,y4]])#必须是array数组的形式rect=cv2.minAre
系统 2019-09-27 17:51:58 2847
将一张图片,切分成九宫格的样式:原图:#-*-coding:UTF-8-*-fromPILimportImageimportsysimportos__author__='kandy'#当前文件所在文件夹DIR_NAME=os.path.dirname(os.path.abspath(__file__))#填充新的imagedeffill_image(image):width,height=image.sizeprint('width:{%d},height
系统 2019-09-27 17:55:26 2846
Pythondatetime/timeconversions«SaltyCraneBlog#timestamptodatetimeobjectinlocaltimetimestamp=1226527167.595983dt_obj=datetime.fromtimestamp(timestamp)printrepr(dt_obj)Pythondatetime/timeconversions«SaltyCraneBlog
系统 2019-08-12 01:32:26 2846
摘要进行数据分析时,GroupBy分组统计是非常常用的操作,也是十分重要的操作之一。基本上大部分的数据分析都会用到该操作,本文将对Python的GroupBy分组统计操作进行讲解。码字不易,喜欢请点赞,谢谢!!!1.GroupBy过程首先看看分组聚合的过程,主要包括拆分(split)、应用(Apply)和合并(Combine)2.创建DataFrameimportpandasaspdipl_data={'Team':['Riders','Riders','
系统 2019-09-27 17:56:17 2845
用Python代码实现棋盘importturtle#导入模块forxinrange(1,20):#用一个循坏画出横线turtle.forward(180)turtle.penup()turtle.goto(0,-x*10)turtle.pendown()turtle.left(90)#调整箭头turtle.penup()turtle.forward(10)turtle.pendown()forxinrange(1,20):#再用一个循环画出竖线turtle
系统 2019-09-27 17:50:33 2845
详细版本见个人博客:Python中list转换array的一个问题我在数据分析过程中需要将list转换为array,但是转换的过程出了一点问题,下面是记录。一、list转换为array的方法下面的a是一个list类型,如果要进行numpy的一些数值运算,我们就需要将它转换为array类型。importnumpyasnpa=[[1,2,3],[4,5,6]]转换如下:importnumpyasnpa=[[1,2,3],[4,5,6]]a_array=np.a
系统 2019-09-27 17:37:40 2845
PyCharm设置代码模板:自动生成文件名、作者、创建日期等信息避免每次新建项目文件时添加注释文件名、作者、创建日期等信息,则可以设置较好的代码模板,在创建文件时自动生成相关信息。设置步骤:打开PyCharm,选择File-->Settings-->Editor-->CodeStyle-->FileandCodeTemplates-->PythonScript生成效果:其设计的模板规范如下:#!/usr/bin/envpython#-*-coding:UT
系统 2019-09-27 17:52:05 2844