python
xiaojay2008
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
python pil模块
from PIL import Imageim = Image.open()2009-03-06 15:49:27 · 134 阅读 · 0 评论 -
python html 转义相关
1ord(s or unicode) 返回十进制 code point;反函数 unichr chr[code]ord(unicode(str, 'u8'))[/code][url]http://crazier9527.iteye.com/blog/411001[/url][url] http://docs.python.org/howto/unicode.html[u...2010-11-26 21:33:51 · 101 阅读 · 0 评论 -
django 服务器 部署方式
1 比较简单好用的 nginx + uwsgi具体见这篇blog http://obmem.info/?p=703要求: ubuntu10。04 +2 用cherrypyhttp://lincolnloop.com/blog/2008/mar/25/serving-django-cherrypy/启动命令(后台):./manage.py runcpserver host...2010-12-07 11:33:16 · 153 阅读 · 0 评论 -
python 包管理note
1 python setup.py develop开发模式:创建链接到当前文件夹,你修改源码,立刻反应出来2011-07-16 00:38:41 · 105 阅读 · 0 评论 -
pyres 后台队列
pyres 是一个后台消息调控队列1 失败重试 retry_every 每隔多少时间retryretry_timeout 整个retry过程最多用时2 指定时间的任务enqueue_at(a, ...)a是一个datetime类变量,其他的和enqueue一样3 参数必须是 JSON serializable, so 传递个函数就不行not JSON s...2011-07-17 22:22:18 · 146 阅读 · 0 评论 -
python redis note
import redisr = redis.Redis()查看所有keysr.keys()or r.keys('*')删除所有keynames = r.keys()r.delete(names)查看key的typer.type(key)redis 文档中文翻译 http://redis.readthedocs.org/en/lates...2011-07-26 09:43:29 · 109 阅读 · 0 评论 -
python time模块
http://wiki.python.org/moin/WorkingWithTime1 三种数据格式:seconds:floattuplestring2 数据转化3 In [17]: datetime.datetime.fromtimestamp(time.time())Out[17]: datetime.datetime(2012, 11, 15, ...2011-03-19 11:14:12 · 91 阅读 · 0 评论 -
amazon simple email service (ses) 使用小记(python)
1 需要帐号的 access key2 我采用了python的库 https://github.com/pankratiev/python-amazon-ses-api具体代码如下第一步verify你的发出邮件:[code="java"]from amazon_ses import AmazonSES, EmailMessageAccessKeyID = ...你的...2011-08-11 22:11:26 · 1178 阅读 · 0 评论 -
echo server just for debug
用来调试,阻塞、单线程[code="java"]import SocketServerclass EchoRequestHandler(SocketServer.BaseRequestHandler): def handle(self): data = self.request.recv(1024) print data ...2011-12-13 12:09:34 · 119 阅读 · 0 评论 -
virtualenvwrapper tips
[color=blue][size=large]安装[/size][/color]pip install virtualenvwrapper 安装完成后,mkdir ~/Envs 这个是你以后创建的所有env的存储的地方然后在 .bash_profileexport WORKON_HOME=~/Envssource /usr/local/bin/virtualenvwrappe...原创 2013-03-14 11:50:32 · 124 阅读 · 0 评论 -
django1.3 static file
[b]开发时:[/b]1、static file 放在个各个app文件夹的static目录下 以及 settings.py中设置的S TATICFILES_DIRS;2、 settings.py中的STATIC_ROOT 用不到的;[u]3、在urls.py 加入:[code="java"]if settings.DEBUG == True: from django....2012-04-14 13:23:07 · 144 阅读 · 0 评论 -
bitbucket 使用初记
bitbucket.com 最近提供免费的 不公开的代码 hosting 服务。所以试了下,准备作为私人代码库。bitbucket.com采用 mercurial 版本管理工具。mercurial教程http://www.ibm.com/developerworks/cn/opensource/os-cn-mercurial/在bitbucket.com开一个respo...2010-11-18 09:29:30 · 256 阅读 · 0 评论 -
mongodb 学习笔记1-mac 安装
1 mac 安装brew install mongodb查看安装的文件 brew list mongodb2 新建数据dirsudo mkdir -p /data/db3 启动server: sudo mongodclient shell: sudo mongo4 pymongohttp://superuser.com/questions/12140...2011-06-17 17:13:17 · 103 阅读 · 0 评论 -
用python分析apache log
需求:最近在浪点买了个虚拟主机,建了个小网站。想要通过分析apache log来得到来访着的信息,比如地理位置(具体到省份,这个是google analytics 没法提供的。) 实现:代码及相关文件(其中ip数据库文件QQWry.Dat较大)svn checkout https://xiaojaylib.googlecode.com/svn/trunk/alog alog...2009-03-11 23:39:27 · 262 阅读 · 0 评论 -
setup的写法
例子:setup.pyfrom distutils.core import setupsetup(name='Distutils', version='1.0', description='Python Distribution Utilities', author=...2010-03-05 10:36:43 · 612 阅读 · 0 评论 -
gae tips
Q:key_name 是不是唯一的?A:yes. 不过你创建一个与原来有相同key_name的entity的时候,google不会报错;只是覆盖原来的entityQ:Admin Console 的 log 的时区是?Pacific Time Zone http://en.wikipedia.org/wiki/Pacific_Time_Zone现在(2009.7.1)貌似是...2009-06-26 20:31:17 · 113 阅读 · 0 评论 -
单独运行测试google app engine datastore的脚本
其中google_engine包放在主目录下ipython中:run set_db_env.pyset_db_env.py 在这里 http://code.google.com/p/xiaojaylib/source/browse/trunk/gae/gae_test/set_db_env.py2009-06-26 20:37:30 · 165 阅读 · 0 评论 -
一个测量python 函数运行时间的 decorator
#coding=utf-8import timeit,mathclass TimeMeth(object): def __init__(self, orig_func): self.f = orig_func def __call__(self, *args, **kwargs): start = timeit.defau...2009-06-30 10:05:23 · 303 阅读 · 0 评论 -
python 正则
1 .*? 非贪婪2 re.DOTALL 匹配所有字符,包括换行符\n。匹配多行是flag要设置这个原创 2010-01-26 11:37:36 · 97 阅读 · 0 评论 -
supervisor 管理后台进程
[url=http://blog.yangyubo.com/tag/supervisor/]参考这篇文章[/url]加上一些notes:1 生成默认conf文件: echo_supervisord_conf > ...2 启动:superviserd -c 配置文件path eg:supervised -c t.ini 配置文件ini格式3 ...2009-08-17 11:29:30 · 186 阅读 · 0 评论 -
python unicode tips
1 mac上ipython 需要用 sudo easy_install -U ipython readline 来修正 中文显示问题2 以下代码 ipython 终端中执行 和py文件直接执行 不一致:[code="python"]u'中' == unicode('中', 'u8')[/code]...2011-01-24 09:59:58 · 109 阅读 · 0 评论 -
nginx+ uwsgi 在ubntu11.04上的安装、配置
[b]0 安装[/b]sudo add-apt-repository ppa:uwsgi/releasehttp://www.zhimaq.com/questions/1151/uwsgi[b]1 uwsgi 的process 接收的信号[/b]http://projects.unbit.it/uwsgi/wiki/uWSGISignals修改代码候,重新载入 kill...原创 2011-05-13 15:37:07 · 100 阅读 · 0 评论 -
Virtualenv 簡單入門 (转载)
转载自 http://blog.gasolin.idv.tw/2010/02/virtualenv.htmlVirtualenv 簡單入門功用使用 Virtualenv 可以讓你預先建立一個虛擬環境,在虛擬環境中開發 Python 程式,可以保持 Python path 乾淨,並減少因為機器上需要同時支援不同版本函式庫,造成各函式庫彼此之間相依性的困擾。而且使用虛擬環境...原创 2011-09-07 09:15:10 · 116 阅读 · 0 评论 -
django south tips
1 安装sudo pip install south在 settings.py 的 installed_app 添加south./manage.py syncb 将south的表同步到db2 south 针对每个app全新的app一./manage.py schemamigration appname --initial在app目录下添加了m...2012-11-17 11:29:03 · 137 阅读 · 0 评论
分享