原始出处: ? ? ? ? ? ? ? ? ? ?In the Milky way ? ? ? ? ? ? ? ? 我不想用很多时间去描述Gevent是什么,我想它官网上的一句总结足矣: “Gevent是一种基于协程的Python网络库,...
分类:
其他好文 时间:
2014-07-22 09:03:03
阅读次数:
288
相比于windows的图形方式,ubuntu的命令行显得简单很多,但是每次需要打开命令行去寻找路径,打开应用程序还是不方便。 以下使用python写了一个小脚本,方便启动常用的工具,初学python,还请多指教,hehe。 #cod...
分类:
编程语言 时间:
2014-07-22 08:37:36
阅读次数:
190
1、使用文件 #?encoding:?utf-8
#?!/usr/bin/python
#?Filename?:?helloworld.py
peom?=?‘‘‘如梦令?李清照
常记溪亭日暮,
沉醉不知归路。
兴尽晚回舟,
误入藕花深处。
争渡,争渡,
惊起一滩鸥鹭。‘...
分类:
编程语言 时间:
2014-07-22 08:31:34
阅读次数:
222
1,安装环境:centos 6.4 python 2.6.6 2,安装easy_install 工具: wget -q http://peak.telecommunity.com/dist/ez_setup.py python ez_setup.py 3, easy_install?cocos2d...
分类:
编程语言 时间:
2014-07-22 08:22:37
阅读次数:
254
Pipes have no names, and their biggest disadvantage is that they can be used ?only?between processes that have a parent process in common. Two unrelated processes can-? not create a pipe betwee...
分类:
其他好文 时间:
2014-07-21 10:36:45
阅读次数:
237
前一篇博文提到怎么得到汉字字库,这篇文章讲怎么把一个一个的字转成图片,这在机器学习中会有用处。
一句话,用pygame渲染文字到图片上。
下面上代码。
import os
import pygame
chinese_dir = 'chinese'
if not os.path.exists(chinese_dir):
os.mkdir(chinese_dir)
pygame.ini...
分类:
编程语言 时间:
2014-07-20 11:43:38
阅读次数:
334
问题1:假设我们知道汉字编码范围是0x4E00到0x9FA5,怎么从十六进制的编码转成人类可读的字呢?
问题2:怎么把unicode编码的字写入文件呢,如果直接用open()的话,会提示UnicodeEncodeError: 'ascii' codec can't encode character u'\u4e00' in position 0: ordinal not in range(128...
分类:
编程语言 时间:
2014-07-20 10:46:08
阅读次数:
732
fromshimportifconfigprint(ifconfig("wlan0"))详见http://amoffat.github.io/sh/
分类:
编程语言 时间:
2014-07-20 10:36:18
阅读次数:
209
CrawlSpider-爬取一般网站常用的spider。其定义了一些规则(rule)来提供跟进link的方便的机制。 也许该spider并不是完全适合您的特定网站或项目,但其对很多情况都使用。 因此您可以以其为起点,根据需求修改部分方法。当然您也可以实现自己的spider。...
分类:
其他好文 时间:
2014-07-20 10:18:09
阅读次数:
225
1.不相交集是解决等价关系的一种数据结构,执行合并和查找的速度都非常快,M次运行合并和查找的运行时间为(M*logN)。
在一个集合中,对于每一对元素(a,b),a,b∈S,对于关系R如果满足下面三个条件,则成关系R为等价关系:
(1)自反性 对于所有a∈S,aRa
(2)对称性 aRb当且仅当bRa
(3)传递性 若aRb且bRc,则aRc
有关不相交集的介绍...
分类:
编程语言 时间:
2014-07-20 10:14:09
阅读次数:
321