随笔分类 -  python

摘要:一直想自己写个python的短信平台,利用短信modem做接口,实现与手机双向信息互通和远程控制,近期google发现了rapidsms这个框架,正是我所想和需要的框架。rapidsms框架主要集成了django作为web界面的实现和后台数据库的管理, 底层使用了一个叫pygsm的库与modem交互, 这个库单独也可以用,收发短信十分方便,同时也支持短信网关的模式。rapidsms安装: 如果pygsm没安装,先安装pygsm,https://github.com/rapidsms/pygsm 简单的easy_install rapidsms 就ok了 ,会自动处理依赖关系,安装依赖的库和包。 阅读全文
posted @ 2012-03-23 12:04 babykick 阅读(1080) 评论(0) 推荐(0)
摘要:一些库和dev包对应关系,安装python模块的时候有时会用到:python: python-devopenssl: libssl libssl-devlibxml2: libxml2-dev libxslt-dev 阅读全文
posted @ 2012-03-08 23:59 babykick 阅读(1223) 评论(0) 推荐(0)
摘要:安装有个地方要注意路径 ,如果以前安装过其他的版本,可能会导致安装位置错误,exscript脚本会报DistributionNotFound错误。如果发现有这个问题使用SITE_DIR指明安装位置:sudo make install SITE_DIR=/usr/python27/lib/python2.7/site-packages/ 阅读全文
posted @ 2012-03-07 17:06 babykick 阅读(430) 评论(0) 推荐(0)
摘要:python twisted教程 一,异步编程发布于: August 17, 2011, 11:45 pm 分类: Twisted 作者: cyrec 阅读: [214]转自:http://www.notedit.com/原文:http://krondo.com/blog/?p=1209前言最近有人在twisted邮件列表中问有没有一个可以让人快速学习twisted的文档.总体的来说:这个系列不是这样的一个文档.如果你没有很多时间或者耐心的话,这个系列的文章不太适合你.不过,如果你对异步编程了解很少的话,相信一个简短的介绍也不让你完全明白,当然如果你是天才除外.我学习和使用twisted已经好 阅读全文
posted @ 2012-03-06 09:58 babykick 阅读(1310) 评论(0) 推荐(0)
摘要:用__dict__把dict转换为对象的属性1 class Messenger:2 def __init__(self, **kwargs):3 self.__dict__ = kwargs4 5 6 m = Messenger(info="some information", b=[’a’, ’list’])7 m.more = 118 print m.info, m.b, m.more以下为转载:Python 用下划线作为变量前缀和后缀指定特殊变量_xxx 不能用’from module import *’导入__xxx__ 系统定义名字__xxx 类中的私有变量名.. 阅读全文
posted @ 2012-03-05 19:46 babykick 阅读(1420) 评论(0) 推荐(0)
摘要:The only constraint on the result of a decorator is that it be callable, so it canproperly replace the decorated function.decorator唯一限制是它必须是callable的,所以如果class作为decorator必须实现__call__方法使其成为callable的对象,而函数本身就是callable的。用class做decorator 1 class my_decorator(object): 2 def __init__(self, f): 3 ... 阅读全文
posted @ 2012-03-05 19:27 babykick 阅读(394) 评论(0) 推荐(0)
摘要:我来回答吧,windows 下安装pygraphviz:1.首先安装graphviz, http://www.graphviz.org/pub/graphviz/stable/windows/graphviz-2.28.0.msi2.下载pygraphviz源码包,http://pypi.python.org/packages/source/p/pygraphviz/pygraphviz-1.1.zip#md5=9b9958f10bdf29c06d9f43e225f6ac0c3. 解压后修改setup.py,三个地方要改 library_path=r'D:\develop\Graphv 阅读全文
posted @ 2012-03-05 13:19 babykick 阅读(1582) 评论(0) 推荐(0)
摘要:linux设置python环境变量(2012-02-08 14:41:24)转载▼添加环境变量主要是在/etc/profile中 例如,在/usr/local/下安装了python2.7 因为系统默认是2.4,所以 #pythonPython 2.4.3 (#1, Sep3 2009, 15:37:37) [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2 Type "help", "copyright", "credits" or "license" for mor 阅读全文
posted @ 2012-03-05 09:38 babykick 阅读(32268) 评论(0) 推荐(1)
摘要:Fabric exscriptpyexpectciscoconfparse 阅读全文
posted @ 2012-03-04 19:30 babykick 阅读(710) 评论(0) 推荐(0)
摘要:web.py的校验码生成2009-12-23 9:28修改自另一位网友的python校验码,原本是用于Django的。因为最近学习web.py的原因,就稍作修改了。这里还需要添加session的处理#coding=utf-8import random, Image, ImageDraw, ImageFont, md5, datetime, ImageColor, StringIO# get random colordef get_color(): colors = ['Black','Orange','Red','Brown',& 阅读全文
posted @ 2012-01-29 16:41 babykick 阅读(486) 评论(0) 推荐(0)
摘要:一、什么是 WSGI 。在认识 flup 之前,得先认识一下 WSGI 。WSGI 的全称为: Python Web Server Gateway Interface v1.0 (Python Web 服务器网关接口),它是 Python 应用程序和 WEB 服务器之间的一种借口,更多详细的细节,可以参考 PEP333 。它的作用,类似于FCGI 或 FASTCGI 之类的协议的作用。WSGI 的目标,是要建立一个简单的普遍适用的服务器与 WEB 框架之间的接口。WSGI 的特点是:简单、可移植等。二、什么是 flup 。WSGI 还只是一种规范,一种标准,它要完成的作用是用来定义 Pytho 阅读全文
posted @ 2012-01-20 17:20 babykick 阅读(1430) 评论(0) 推荐(0)
摘要:这是国外网站上的一篇文章,详细的讲解了python wsgi,对理解python的web框架很有帮助原文:http://lucumr.pocoo.org/2007/5/21/getting-started-with-wsgi/Getting Started with WSGIwritten on Monday, May 21, 2007I finally finished the written matura and have some more time to work on projects and write articles. One of the things I wanted to 阅读全文
posted @ 2012-01-20 16:59 babykick 阅读(728) 评论(0) 推荐(0)
摘要:nginx上用fastcgi配置python环境(一)2010-09-02 17:39:15|分类: Apache/Nginx |标签:wsgiflupfcgipythonnginx |字号大中小订阅 费了2天的功夫,翻阅了无数的中文、英文资料,终于搞定。写下此文留待以后翻阅用 本文环境,centOS 5.4 ,Nignx-0.8.49, Python 2.6.5===================================================================================== WSGI是Python应用程序或框架和Web服务器之间... 阅读全文
posted @ 2012-01-20 15:09 babykick 阅读(1340) 评论(0) 推荐(0)
摘要:过去的这个月,接触的最多的就是Python的WSGI了,WSGI不是框架不是模块,仅仅是一个规范协议,定义了一些接口,却影响着Python网络开发的方方面面。对于WSGI有这么一段定义:WSGI is theWeb Server Gateway Interface. It is a specification for web servers and application servers to communicate with web applications (though it can also be used for more than that).我想我这篇文章不是详细介绍WSGI内容 阅读全文
posted @ 2012-01-20 15:09 babykick 阅读(4332) 评论(0) 推荐(2)
摘要:【Python】 Python:locals 和 globals2011-09-09 14:27 64人阅读 评论(0) 收藏 举报静夜思 » 日志 » Python:locals 和 globals热1发表于2010-03-21 23:32 已有678人读过 标签: Python globals localsPython有两个内置的函数,locals 和globals,它们提供了基于字典的访问局部和全局变量的方式。首先,是关于名字空间的一个名词解释。是枯燥,但是很重要,所以要耐心些。Python使用叫做名字空间的东西来记录变量的轨迹。名字空间只是一个字典,它的键字就是变量 阅读全文
posted @ 2012-01-20 11:14 babykick 阅读(3301) 评论(0) 推荐(0)
摘要:setup { package_data = ['', ['*.txt']]}不起作用,打包为源代码的时候并没有把package下的txt文件放进去。找到setuptools的官方文档,有这么一段话:This tells setuptools to install any data files it finds in your packages. The data files must be under CVS or Subversion control, or else they must be specified via the distutils' 阅读全文
posted @ 2012-01-18 16:15 babykick 阅读(8575) 评论(0) 推荐(0)
摘要:1. The Engine opens a domain, locates the Spider that handles that domain, and asks the spider for the first URLsto crawl.2. The Engine gets the first URLs to crawl from the Spider and schedules them in the Scheduler, as Requests.3. The Engine asks the Scheduler for the next URLs to crawl.4. The Sch 阅读全文
posted @ 2012-01-17 21:23 babykick 阅读(1374) 评论(0) 推荐(0)
摘要:Python字符编码详解2011-01-03 13:25:45本文简单介绍了各种常用的字符编码的特点,并介绍了在python2.x中如何与编码问题作战 :)请注意本文关于Python的内容仅适用于2.x,3.x中str和unicode有翻天覆地的变化,请查阅其他相关文档。尊重作者的劳动,转载请注明作者及原文地址 >.<转自http://hi.baidu.com/mxp446533129/blog/item/ab55d625d7e95c12918f9df0.html1. 字符编码简介1.1. ASCIIASCII(American Standard Code for Informat 阅读全文
posted @ 2012-01-03 21:17 babykick 阅读(312) 评论(0) 推荐(0)
摘要:csv模块不支持直接用unicode写入,没什么好方法,使用dict comprehension转换一下# coding: utf-8import csvD ={'name':u'马克','pinyin':u'mǎkè'}f = open('out.csv','wb')f.write(u'\ufeff'.encode('utf8'))# BOM (optional...Excel needs it to open UTF-8 file properly)w 阅读全文
posted @ 2011-12-31 11:23 babykick 阅读(1087) 评论(0) 推荐(0)
摘要:安装pcap首先下载http://www.winpcap.org/install/bin/WpdPack_4_0_2.zip下载pypcap源代码包pypcap-1.1,解压1)如果没有安装mingw32 下载安装一个 假设安装到c:\wingw322) 设置环境变量 path=%path%;c:\wingw32\bin3)将上面下载的WpdPack(winpcap development pack) 解压到c:\WpdPack4)进入pypcap-1.1解压的目录,依次执行:> python .\setup.py config --with-pcap="C:\WpdPack& 阅读全文
posted @ 2011-12-26 16:45 babykick 阅读(4017) 评论(1) 推荐(0)