首页 文章 精选 留言 我的

精选列表

搜索[python解释器],共10000篇文章
优秀的个人博客,低调大师

【机器学习工具榜单】Tensorflow最多使用,Python 取代 R 成最受欢迎编程语言

近日,KDnuggets网站公布了2018年度的数据科学和机器学习工具调查结果。2300多名参与者对自己“过去 12 个月内在项目开发中使用过的数据挖掘 / 机器学习工具和编程语言”进行了投票。 最受欢迎的分析、数据科学、机器学习工具 图1:2018年最受欢迎的分析/数据科学/机器学习工具,以及与2016~2017年调查结果的对比 下表列举了最受欢迎的前11个工具,其中每个的占比都达到20%以上。 表1:2018年最受欢迎的分析/数据科学/ 机器学习软件Top 10 上表中,2018 % share 是指使用这个工具的人占所有投票者的百分比,% change是指2018年相较2017年的投票变化。 每个受访者平均使用的工具数量为7.0个,略高于2017年的6.75个(排除了只选择1个工具的投票)。 与2017年的软件调查相比,今年新进入Top

优秀的个人博客,低调大师

Python-OpenCV学习(七)边界框、最小矩形区域和最小闭圆的轮廓:

边界框、最小矩形区域和最小闭圆的轮廓:找到一个正方形轮廓很简单 找不规则的、歪斜的以及旋转的形状可用OpencV的cv2.findContours函数。 import cv2 import numpy as np img = cv2.pyrDown(cv2.imread("hammer.jpg", cv2.IMREAD_UNCHANGED)) ret, thresh = cv2.threshold(cv2.cvtColor(img.copy(), cv2.COLOR_BGR2GRAY) , 127, 255, cv2.THRESH_BINARY) image, contours, hier = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) for c in contours: # find bounding box coordinates x,y,w,h = cv2.boundingRect(c) cv2.rectangle(img, (x,y), (x+w, y+h), (0, 255, 0), 2) # find minimum area rect = cv2.minAreaRect(c) # calculate coordinates of the minimum area rectangle box = cv2.boxPoints(rect) # normalize coordinates to integers box = np.int0(box) # draw contours cv2.drawContours(img, [box], 0, (0,0, 255), 3) # calculate center and radius of minimum enclosing circle (x,y),radius = cv2.minEnclosingCircle(c) # cast to integers center = (int(x),int(y)) radius = int(radius) # draw the circle img = cv2.circle(img,center,radius,(0,255,0),2) cv2.drawContours(img, contours, -1, (255, 0, 0), 1) cv2.imshow("contours", img) cv2.waitKey() cv2.destroyAllWindows() 结果:加载图片后先进行阈值处理,由于原图为黑白图片所以阈值较为简单计算简单的边界框: x,y,w,h=cv2.boundingRect(c) 转化为框的坐标及宽度,再画出框: cv.rectangle(img,(x,y),(x+w,y+h),(0,255,0),2) 第二步计算出包围最小的矩形区域 rect = cv2.minAreaRect(c) # calculate coordinates of the minimum area rectangle box = cv2.boxPoints(rect) # normalize coordinates to integers box = np.int0(box) 注意计算所得的顶点坐标为浮点型的,像素坐标必须为整数,所以必须做一个转换,然后画出这个矩形,可以用cv2.drawContours函数来: cv2.drawContours(img,[box],0,(0,0,255),3) 该函数的第二个参数接收一个保存着轮廓的数组,从而可以在一次操作中绘制一系列轮廓。第三个参数为所要绘制的轮廓的索引,-1为绘制所有的轮廓,否则只会绘制轮廓组中指定的轮廓最后检查的边界轮廓为最小闭圆: (x,y),radius = cv2.minEnclosingCircle(c) # cast to integers center = (int(x),int(y)) radius = int(radius) cv2.minEnclosingCircle函数会返回一个二元组,第一个元素为圆心坐标组成的元组,第二个元素为圆的半径值。

优秀的个人博客,低调大师

python3.6抓取出现TypeError: cannot use a string pattern on a bytes-like ob...

import reimport requestsfrom requests.exceptions import RequestExceptionimport jsondef get_one_page(url):try: response = requests.get(url)if response.status_code == 200:return response.contentreturn None except RequestException:return Nonedef parse_page_html(html): pattern = re.compile('<dd>.*?board-index.*?>(\d+)</i>.*?data-src="(.*?)".*?name"><a'+ '.*?>(.*?)</a>.*?star">(.*?)</p>.*?releasetime">(.*?)</p>'+ '.*?integer">(.*?)</i>.*?fraction">(.*?)</i>.*?</dd>', re.S) items = re.findall(pattern, html)for item in items:yield {'index':item[0],'image':item[1],'title':item[2],'actor':item[3].strip()[3:],'time':item[4].strip()[5:],'score':item[5]+item[6] }def write_to_file(content):with open('result.txt','a',encoding='utf-8') as f: f.write(json.dumps(content,ensure_ascii=False)+'\n') f.close()def main(): url = 'http://maoyan.com/board/4?' html = get_one_page(url)for item in parse_page_html(html): write_to_file(item)if __name__ == '__main__': main() 如果没有以上红色代码,会出现TypeError: cannot use a string pattern on a bytes-like object,只需要加上html = html.decode('utf-8')即可

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册