![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
xiaojay2008
这个作者很懒,什么都没留下…
展开
-
python pil模块
from PIL import Image im = Image.open()2009-03-06 15:49:27 · 77 阅读 · 0 评论 -
python html 转义相关
1 ord(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 · 66 阅读 · 0 评论 -
django 服务器 部署方式
1 比较简单好用的 nginx + uwsgi 具体见这篇blog http://obmem.info/?p=703 要求: ubuntu10。04 + 2 用cherrypy http://lincolnloop.com/blog/2008/mar/25/serving-django-cherrypy/ 启动命令(后台): ./manage.py runcpserver host...2010-12-07 11:33:16 · 98 阅读 · 0 评论 -
python 包管理note
1 python setup.py develop 开发模式:创建链接到当前文件夹,你修改源码,立刻反应出来2011-07-16 00:38:41 · 61 阅读 · 0 评论 -
pyres 后台队列
pyres 是一个后台消息调控队列 1 失败重试 retry_every 每隔多少时间retry retry_timeout 整个retry过程最多用时 2 指定时间的任务 enqueue_at(a, ...) a是一个datetime类变量,其他的和enqueue一样 3 参数必须是 JSON serializable, so 传递个函数就不行 not JSON s...2011-07-17 22:22:18 · 102 阅读 · 0 评论 -
python redis note
import redis r = redis.Redis() 查看所有keys r.keys() or r.keys('*') 删除所有key names = r.keys() r.delete(names) 查看key的type r.type(key) redis 文档中文翻译 http://redis.readthedocs.org/en/lates...2011-07-26 09:43:29 · 67 阅读 · 0 评论 -
python time模块
http://wiki.python.org/moin/WorkingWithTime 1 三种数据格式: seconds:float tuple string 2 数据转化 3 In [17]: datetime.datetime.fromtimestamp(time.time()) Out[17]: datetime.datetime(2012, 11, 15, ...2011-03-19 11:14:12 · 51 阅读 · 0 评论 -
amazon simple email service (ses) 使用小记(python)
1 需要帐号的 access key 2 我采用了python的库 https://github.com/pankratiev/python-amazon-ses-api 具体代码如下 第一步 verify你的发出邮件: [code="java"] from amazon_ses import AmazonSES, EmailMessage AccessKeyID = ...你的...2011-08-11 22:11:26 · 854 阅读 · 0 评论 -
echo server just for debug
用来调试,阻塞、单线程 [code="java"] import SocketServer class EchoRequestHandler(SocketServer.BaseRequestHandler): def handle(self): data = self.request.recv(1024) print data ...2011-12-13 12:09:34 · 74 阅读 · 0 评论 -
virtualenvwrapper tips
[color=blue][size=large]安装[/size][/color] pip install virtualenvwrapper 安装完成后,mkdir ~/Envs 这个是你以后创建的所有env的存储的地方 然后在 .bash_profile export WORKON_HOME=~/Envs source /usr/local/bin/virtualenvwrappe...原创 2013-03-14 11:50:32 · 79 阅读 · 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 · 91 阅读 · 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 · 211 阅读 · 0 评论 -
mongodb 学习笔记1-mac 安装
1 mac 安装 brew install mongodb 查看安装的文件 brew list mongodb 2 新建数据dir sudo mkdir -p /data/db 3 启动 server: sudo mongod client shell: sudo mongo 4 pymongo http://superuser.com/questions/12140...2011-06-17 17:13:17 · 68 阅读 · 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 · 194 阅读 · 0 评论 -
setup的写法
例子:setup.py from distutils.core import setup setup ( name = 'Distutils' , version = '1.0' , description = 'Python Distribution Utilities' , author = ...2010-03-05 10:36:43 · 526 阅读 · 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 · 71 阅读 · 0 评论 -
单独运行测试google app engine datastore的脚本
其中google_engine包放在主目录下 ipython中: run set_db_env.py set_db_env.py 在这里 http://code.google.com/p/xiaojaylib/source/browse/trunk/gae/gae_test/set_db_env.py2009-06-26 20:37:30 · 103 阅读 · 0 评论 -
一个测量python 函数运行时间的 decorator
#coding=utf-8 import timeit,math class 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 · 225 阅读 · 0 评论 -
python 正则
1 .*? 非贪婪 2 re.DOTALL 匹配所有字符,包括换行符\n。匹配多行是flag要设置这个原创 2010-01-26 11:37:36 · 57 阅读 · 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 · 134 阅读 · 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 · 67 阅读 · 0 评论 -
nginx+ uwsgi 在ubntu11.04上的安装、配置
[b]0 安装 [/b]sudo add-apt-repository ppa:uwsgi/release http://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 · 60 阅读 · 0 评论 -
Virtualenv 簡單入門 (转载)
转载自 http://blog.gasolin.idv.tw/2010/02/virtualenv.html Virtualenv 簡單入門 功用 使用 Virtualenv 可以讓你預先建立一個虛擬環境,在虛擬環境中開發 Python 程式,可以保持 Python path 乾淨,並減少因為機器上需要同時支援不同版本函式庫,造成各函式庫彼此之間相依性的困擾。 而且使用虛擬環境...原创 2011-09-07 09:15:10 · 65 阅读 · 0 评论 -
django south tips
1 安装 sudo pip install south 在 settings.py 的 installed_app 添加south ./manage.py syncb 将south的表同步到db 2 south 针对每个app 全新的app 一 ./manage.py schemamigration appname --initial 在app目录下添加了m...2012-11-17 11:29:03 · 83 阅读 · 0 评论