Tag Archives: python

让 Apache 支持 mod_python

mod_pytho 中文文档 http://man.chinaunix.net/develop/python/mod_python/mod_python.html 1, 下载 ModPython-3.3.1 (http://www.apache.org/dist/httpd/modpython/win/3.3.1/), 安装, 安装过程中会讯问 apache 安装目录. 2, 在apache的httpd.conf中加入下面一行: LoadModule python_module modules/mod_python.so 3, 再加入下面一段 Alias /py/ "d:/PythonCode/" <Directory "d:/PythonCode/"> AddHandler mod_python .py #PythonHandler mptest PythonHandler mod_python.publisher PythonDebug On </Directory> 4, 在 d:/PythonCode/ 目录下新建一名为 mptest.py 的测试文件,内容如下 from mod_python import apache def handler(req): req.content_type = "text/plain" req.write("Hello World!") return apache.OK 5, 通过 http://127.0.0.1/py/mptest.py [...]
Posted in Apache, Python | Also tagged | Leave a comment

python 连接 mysql

部分内容参考自: http://mysql-python.sourceforge.net/MySQLdb.html http://peak.telecommunity.com/DevCenter/EasyInstall http://blog.sina.com.cn/s/blog_57b671b601008bsw.html 1, 下载 MySQLdb 的库 下载地址 http://sourceforge.net/projects/mysql-python 会得到一个 *.egg (类似 MySQL_python-1.2.2-py2.4-win32.egg )
Posted in Mysql, Python | Also tagged | Leave a comment

自制 python 批量压图程序

自个儿的相册缩图程序, 图个方便~ python 写的, 纯当练练手. #!/usr/bin/env python #coding=utf-8 import Image import os import sys def go(in_dir, out_dir="", recursion="1"): ''' 准备,开始! ''' if out_dir=="": out_dir = in_dir list_dir(in_dir, out_dir, recursion) def list_dir(in_dir, out_dir, recursion): ''' 递归子目录, 如果是图片则开始压图, 如果是子目录,继续深入 ''' for listName in os.listdir(in_dir): if os.path.isdir(in_dir+listName): childInDirName = in_dir+listName+'/' childOutDirName = out_dir+listName+'/' if os.path.isdir(childOutDirName)==False: os.mkdir(childOutDirName) #print childInDirName+"\t"+childOutDirName [...]
Posted in Python, Tool | Tagged | Leave a comment