mac下安装scrapy的各种艰辛
1.没有pip工具包,安装 :终端下 ,wget https://bootstrap.pypa.io/get-pip.py 安装pip:sudo python get-pip.py 2.修改pip源码地址(国外地址太慢) Mac配置 .pip/pip.conf mkdir .pip touch pip.conf vim 打开pip.conf 填写: [global] index-url =...
View Article[原]事件循环开发框架eventloop(python版)
基于不同操作系统提供的多路IO通知机制,实现了一个可以针对文件描述符或者同类结构进行事件监听开发的小型框架,基于tornado的IOLoop实现。主要结构如下: LoopImpl类 依据不同操作系统,按照epoll的接口实现了统一的loop注册方式: class LoopImpl(object): """ Base class for concrete implementations of...
View ArticleImport Python: ImportPython 100th Issue - Python Quiz, Building a Financial...
Import python 100th Issue Quiz It's been 2 years of curating ImportPython and today is the 100th Issue. Wow. What a moment ?. Here is a python quiz competition. Five random() participants who answer...
View Article主题模型初学者指南[Python]
主题模型初学者指南[python] 引言 近年来涌现出越来越多的非结构化数据,我们很难直接利用传统的分析方法从这些数据中获得信息。但是新技术的出现使得我们可以从这些轻易地解析非结构化数据,并提取出重要信息。 主题模型是处理非结构化数据的一种常用方法,从名字中就可以看出,该模型的主要功能就是从文本数据中提取潜在的主题信息。主题模型不同于其他的基于规则或字典的搜索方法,它是一种无监督学习的方法。...
View ArticleTalk Python to Me: #86 Python at StackOverflow
If you run into a problem with some API or python code what do you do to solve it? I personally through a few keywords into google, sometimes even before checking the full docs. Why does this work?...
View Article“Get back to where you once belonged…”
I recently ran into the situation where I wanted to be able to return from a form to the previous view. There was not a way to add kids to the system (short of using the admin portal) and there were...
View Article机器学习经典算法详解及Python实现
聚类是一种无监督的学习( 无监督学习 不依赖预先定义的类或带类标记的训练实例),它将相似的对象归到同一个簇中,它是观察式学习,而非示例式的学习,有点像全自动分类。 说白了,聚类 (clustering)是完全可以按字面意思来理解的――将相同、相似、相近、相关的对象实例聚成一类的过程。机器学习中常见的聚类算法包括 k-Means算法、期望最大化算法(Expectation...
View ArticlePython中的logging模块
最近修改了项目里的logging相关功能,用到了python标准库里的logging模块,在此做一些记录。主要是从官方文档和stackoverflow上查询到的一些内容。 官方文档 技术博客 基本用法 下面的代码展示了logging最基本的用法。 # -*- coding: utf-8 -*- import logging import sys # 获取logger实例,如果参数为空则返回root...
View ArticleHow to Make Phone Calls in Python
Posted byMatt Makai on November 23, 2016. Good old-fashioned phone calls remain one of the best forms of communication despite the slew of new smartphone apps that have popped up over the past several...
View Article计算机眼中的数字
即使是没上过学的人,也知道答案是0.3,但是,在看似无所不能,计算速度远超人类的计算机来说,答案就不是0.3了。看看chrome下的结果: 0.1 + 0.2 0.30000000000000004 再看看python: Python 2.7.10 (default, Jul 30 2016, 18:31:42) [GCC 4.2.1 Compatible Apple LLVM 8.0.0...
View Article干货分享:Python开发的高级技巧
干货分享:python开发的高级技巧 4小时前来源:51CTO 本文我列出几个Python高级技巧: 1. contextmanager 写Python代码的时候经常将一系列操作放在一个语句块中,Python 2.5加入了with语法,实现上下文管理功能,这让代码的可读性更强并且错误更少。最常见的例子就是open,如果不使用with,使用open会是这样: 如果使用with,可以简化为两行:...
View ArticlePython 语言参考 (TLDR 版 Part I)
本参考手册描述 python 的语法及“核心语义”,简洁但力图精准、完备,如需: 内置对象类型、函数及模块,请参考 Python 标准库 ; Python 教程,请参考 Python 教程 ; 总目录 介绍 词法分析 数据模型 执行模型 导入系统 表达式 简单语句 复合语句 顶层组件 完整语法规范 1. 介绍 1.1. 实现 CPython:最常见常用的 C 语言实现,托管在 GitHub ;...
View ArticlePython 开发的高级技巧
本文我列出几个python高级技巧: 1. contextmanager 写Python代码的时候经常将一系列操作放在一个语句块中,Python 2.5加入了with语法,实现上下文管理功能,这让代码的可读性更强并且错误更少。最常见的例子就是open,如果不使用with,使用open会是这样: 如果使用with,可以简化为两行:...
View ArticleParallel in Python
0. GIL 每一个pythoner对GIL是又爱又恨,GIL给我们提供极大便利的同时,也带来了难以突破的性能瓶颈。我们知道,因为GIL的存在,使得一个python实例只能运行在一个Core上,那有没有办法开启多个GIL,让它们分别跑在不同的Core上,用以提升性能呢?答案是完全可行的,并且最新的python版本已经集成了相应的工具。 1. multiprocessing包...
View Articleefficiency and correctness issues with parallelism in interpreters for...
PyPy is an astoundingly successful endeavor to simplify the implementation of fast JITs for dynamic languages. It’s also, of course, a great implementation of python , a language that has historically...
View ArticlePython识别web验证码
python识别web验证码 一点号编程派5小时前 背景最近公司新项目需要搭建一个自动化测试框架,于是研究了一下selenium这个自动化测试工具,用python写了一个操作网站完成登录的逻辑。 输入用户名、密码点解登录,这些都可以由程序自动完成,但是我们的网站是有验证码的,必须手动输入验证码才能成功登录。这就让测试不是真正意义上的”自动化”了。...
View Article移动H5性能测试平台解决方案
1.平台的目的 说到H5性能测试,大家想到最多的是在PC端利用Firebug、Fiddle和HttpWatch等工具进行测试和性能指标的分析,但是如果我们测试的是Android上的H5,我们该如何保证数据准确度、如何测试起来更方便快捷、如何才能够小白式进行性能测试呢? 2.解决方案...
View ArticleByte Objects vs String in Python
In python 2, both str and bytes are the same typeByte objects whereas in Python 3 Byte objects, defined in Python 3 are “ sequence of bytes ” and similar to “ unicode ” objects from Python 2. However,...
View Articlen8henrie/pycookiecheat: Borrow cookies from your browser's authenticated...
pycookiecheat Borrow cookies from your browser's authenticated session for use in python scripts. Free software: MIT Documentation: http://n8h.me/HufI1w Installation NB:Use pip and python instead of...
View ArticlePython爬虫实战一之爬取糗事百科段子
首先,糗事百科大家都听说过吧?糗友们发的搞笑的段子一抓一大把,这次我们尝试一下用爬虫把他们抓取下来。 友情提示 糗事百科在前一段时间进行了改版,导致之前的代码没法用了,会导致无法输出和CPU占用过高的情况,是因为正则表达式没有匹配到的缘故。 现在,博主已经对程序进行了重新修改,代码亲测可用,包括截图和说明,之前一直在忙所以没有及时更新,望大家海涵!...
View Article