类与类的关系依赖关系#依赖关系:将一个类的类名或者对象传给另一个类的方法中.classElephant:def__init__(self,name):self.name=namedefopen(self,r1):#print(ref1)print(f'{self.name}默念三声:芝麻开门')r1.open_door()defclose(self):print('大象默念三声:芝麻关门')classRefrigerator:def__init__(sel
系统 2019-09-27 17:48:13 1873
fromPILimportImage,ImageFont,ImageDrawdefCreateImg(text):fontSize=30liens=text.split('\n')print(len(liens))im=Image.new("RGB",(480,len(lines)*(fontSize+5)),(255,0,0))dr=ImageDraw.Draw(im)fontPath=r"C:\Windows\Fonts\STKAITI.TTF"#fo
系统 2019-09-27 17:48:05 1873
目录一、概述1.1从数据处理到人工智能二、Python库之数据分析2.1numpy2.2pandas2.3scipy三、Python库之数据可视化3.1matplotlib3.2Seaborn3.3Mayavi四、Python库之文本处理4.1PyPDF24.2NLTK4.3Python-docx五、Python库之机器学习5.1Scikit-learn5.2TensorFlow5.3MXNet六、单元小结6.1从数据处理到人工智能一、概述1.1从数据处理
系统 2019-09-27 17:47:49 1873
在采集网页信息的时候,经常需要伪造报头来实现采集脚本的有效执行下面,我们将使用urllib2的header部分伪造报头来实现采集信息方法1、#!/usr/bin/python#-*-coding:utf-8-*-#encoding=utf-8#Filename:urllib2-header.pyimporturllib2importsys#抓取网页内容-发送报头-1url="//www.jb51.net"send_headers={'Host':'www.
系统 2019-09-27 17:47:48 1873
还是分析一下大体的流程:首先还是Chrome浏览器抓包分析元素,这是网址:https://www.douyu.com/directory/all发现所有房间的信息都是保存在一个无序列表中的li中,所以我们可以先获取一个装有li的element对象的列表,然后在对每个element逐一操作分析斗鱼的翻页,有一个下一页按钮,是个li,class="dy-Pagination-item-custom",但是当烦到最后一页的时候,class="dy-Paginat
系统 2019-09-27 17:47:21 1873
python提供了两个非常重要的功能来处理python程序在运行中出现的异常和错误。你可以使用该功能来调试python程序。1.异常处理:本站Python教程会具体介绍。2.断言(Assertions):本站Python教程会具体介绍。python标准异常异常名称描述BaseException所有异常的基类SystemExit解释器请求退出KeyboardInterrupt用户中断执行(通常是输入^C)Exception常规错误的基类StopIterati
系统 2019-09-27 17:47:18 1873
本文讲述了一个python查找webshell脚本的代码,除了查找webshell功能之外还具有白名单功能,以及发现恶意代码发送邮件报警等功能,感兴趣的朋友可以自己测试一下看看效果。具体的功能代码如下:#!/usr/bin/envpython#-*-coding:utf-8-*-importosimportsysimportreimportsmtplib#设定邮件fromaddr="smtp.qq.com"toaddrs=["voilet@qq.com"]
系统 2019-09-27 17:47:03 1873
因为需要对数据处理,将excel数据导入到数据库,记录一下过程。使用到的库:xlrd和pymysql(如果需要写到excel可以使用xlwt)直接丢代码,使用python3,注释比较清楚。importxlrdimportpymysql#importimportlib#importlib.reload(sys)#出现呢reload错误使用defopen_excel():try:book=xlrd.open_workbook("XX.xlsx")#文件名,把文
系统 2019-09-27 17:47:02 1873
#!/usr/bin/envpython#coding=utf-8importosfrompyinotifyimportWatchManager,Notifier,ProcessEvent,IN_DELETE,IN_CREATE,IN_MODIFYwm=WatchManager()mask=IN_DELETE|IN_CREATE|IN_MODIFY#watchedeventsclassPFilePath(ProcessEvent):defprocess_I
系统 2019-09-27 17:46:53 1873
原文链接:https://www.learnopencv.com/read-an-image-in-opencv-python-cpp/InOpenCVyoucaneasilyreadinimageswithdifferentfileformats(JPG,PNG,TIFFetc.)usingimread.ThebasicusageisshownbelowC++Matimread(conststring&filename,intflags=IMREAD_C
系统 2019-09-27 17:46:26 1873