Quantcast
Channel: CodeSection,代码区,Python开发技术文章_教程 - CodeSec
Browsing all 9596 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

The Power of IPython Notebook + Pandas + and Scikit-learn

Ipython Notebook, Numpy, Pandas, MongoDB, R ― for the better part of a year now, I have been trying out these technologies as part of Udacity’s Data Analyst Nanodegree . My undergrad education barely...

View Article


Mathematical Modules in Python: Decimal and Fractions

Even the most basic mathematical operations can sometimes give anerroneous result. This happens due to limitations in storing the exact value of some numbers. You can overcome these limitations by...

View Article


Python lambda简介

作者:杨冬 欢迎转载,也请保留这段声明。谢谢! 出处: https://andyyoung01.github.io/ 或 http://andyyoung01.16mb.com/ python的lambda函数也叫匿名函数,即,函数没有具体的名称。它可以使代码看起来更简洁,更易理解。 lambda函数也就是匿名函数可以通过如下的表达式定义: lambda args:expression 其中...

View Article

Mike Driscoll: PyDev of the Week: Cameron Simpson

This week we welcome Cameron Simpson as our PyDev of the Week. Cameron is the co-author of PEP 418 Add monotonic time, performance counter, and process time functions and the author of PEP 499 python...

View Article

机器学习(简述)

在入门机器学习之前,我们先了解一些简单的术语: 特征:也称作 属性 训练集:训练机器大脑的样本,包含特征与 目标变量 测试数据:用于测试机器学习算法的效果,测试数据通常不包含 目标变量 ,目标变量有机器学习算法得出 精确度:比较预测结果与实际结果 如何开发机器学习应用程序 收集数据:收集数据的途径很多,爬虫、公开数据源、设备测量数据集等 准备输入数据:确保数据符合 机器学习算法 的格式等要求...

View Article


Easticsearch 数据迁移至influxdb【python】

Easticsearch 数据迁移至influxdb python 需求:将Easticsearch部分数据迁移至influxdb中。 见过从mysql,influxdb迁移至Easticsearch中的,没见过从Easticsearch迁移至influxdb中,迁移的数据是一些实时性的流量数据,influxdb时序性数据库对这类数据的支撑比较客观。...

View Article

Image may be NSFW.
Clik here to view.

Generating movie barcodes with OpenCV and Python

In last week’s blog post I demonstrated how to count the number of frames in a video file . Today we are going to use this knowledge to help us with a computer vision and image processing task ―...

View Article

Image may be NSFW.
Clik here to view.

Julien Danjou: is on its way

My day-to-day activities are still evolving around the python programming language, as I continue working on the OpenStack project as part of my job at RedHat . OpenStack is still the biggest Python...

View Article


centos6.7安装python2.7.11的具体方法

1. 查看本机系统及python版本# cat /etc/redhat-release CentOS release 6.7 (Final)查看CentOS release 6.7 (Final)自带的python版本# python -VPython 2.6.6注意, 我们不要破坏系统的Python环境, 因为几个关键的实用应用程序依赖于系统默认的Python 2.6.6,...

View Article


python subprocess 杀掉全部派生的子进程方法

下面就是今天下午的研究成果。发布系统需要响应用户的中断请求,需要在GET方法中杀掉由subprocess派生的子进程,刚开始直接用os.kill...

View Article

用python记录运行pid,并在需要时kill掉它们的实例

我在跑爬虫程序的时候,由于爬虫程序的等待目标服务器返回数据的时间很长,而cpu占用很低,所以经常挂着代理一跑就跑好几百个。但是爬虫程序通常是写了死循环,或直到分配给该进程的任务都跑完才退出的。如果我们想中途结束掉这些任务,是没办法手工一个一个kill掉的。那么该如何结束这些进程呢?我的方法就是在运行爬虫进程时,记录该进程的Pid,然后在需要手动结束时,再用语句kill掉它们。for i in...

View Article

python 根据pid杀死相应进程的方法

用python语言实现根据pid杀死相应进程kill_process.py代码如下#! /usr/bin/python# -*- coding: utf-8 -*-import osimport sysimport signaldef kill(pid): try: a = os.kill(pid, signal.SIGKILL) # a = os.kill(pid, signal.9) #...

View Article

Image may be NSFW.
Clik here to view.

总结python实现父类调用两种方法的不同

python中有两种方法可以调用父类的方法:super(Child, self).method(args) Parent.method(self, args)我用其中的一种报了如下错误:找不到 classobj。当我把调用改为 super(B, self).f(name) 就能正确运行,且结果正确。分析错误因为基类没有继承 object , 在python中,一个可以这样创建:class A:...

View Article


利用python程序帮大家清理windows垃圾

前言大家应该都有所体会,在windows系统使用久了就会产生一些“垃圾”文件。这些文件有的是程序的临时文件,有的是操作记录或日志等。垃圾随着时间越积越多,导致可用空间减少,文件碎片过多,使得系统的运行速度受到一定影响。而Mac系统和linux系统并不存在这类问题,所以只适用于windows知识概要某些缓存文件可以提高程序的执行速度,比如缓存 cookie、使用记录 recent、预读取...

View Article

Python科学计算之NumPy入门教程

前言NumPy是python用于处理大型矩阵的一个速度极快的数学库。它允许你在Python中做向量和矩阵的运算,而且很多底层的函数都是用C写的,你将获得在普通Python中无法达到的运行速度。这是由于矩阵中每个元素的数据类型都是一样的,这也就减少了运算过程中的类型检测。矩阵基础在 numpy...

View Article


Image may be NSFW.
Clik here to view.

Python科学计算之Pandas详解

起步Pandas最初被作为金融数据分析工具而开发出来,因此 pandas 为时间序列分析提供了很好的支持。 Pandas 的名称来自于面板数据(panel data)和python数据分析 (data analysis) 。panel data是经济学中关于多维数据集的一个术语,在Pandas中也提供了panel的数据类型。在我看来,对于 Numpy 以及 Matplotlib...

View Article

详解Python3中字符串中的数字提取方法

逛到一个有意思的博客在里面看到一篇关于ValueError: invalid literal for int() with base 10错误的解析,针对这个错误,博主已经给出解决办法,使用的是re.sub 方法 totalCount = '100abc' totalCount = re.sub("\D", "", totalCount)...

View Article


Image may be NSFW.
Clik here to view.

win7上python2.7连接mysql数据库的方法

 一:安装mysql-python驱动 pip install mysql二:连接到MySQL服务器的test数据库#!/usr/bin/python# -*- coding: UTF-8 -*-import mysql.connectorif __name__ == "__main__": # 打开数据库连接 conn=mysql.connector.connect(host='IP',...

View Article

python实现字符串连接的三种方法及其效率、适用场景详解

python字符串连接的方法,一般有以下三种:方法1:直接通过加号(+)操作符连接website = 'python' + 'tab' + '.com' 方法2:join方法 listStr = ['python', 'tab', '.com'] website = ''.join(listStr) 方法3:替换 website = '%s%s%s' % ('python', 'tab',...

View Article

python实现读取并显示图片的两种方法

在 python 中除了用 opencv,也可以用 matplotlib 和 PIL 这两个库操作图片。本人偏爱 matpoltlib,因为它的语法更像 matlab。一、matplotlib1. 显示图片import matplotlib.pyplot as plt # plt 用于显示图片import matplotlib.image as mpimg # mpimg 用于读取图片import...

View Article
Browsing all 9596 articles
Browse latest View live