Linux下Python网络编程框架-Twisted安装手记

Twisted是下的用来进行网络服务和应用程序编程的框架,安装Twisted前需要系统预先安装有
一、安装Twisted
1、下载Twisted
这里下载Twisted,有win32,source,mac版本,win32下有支持python2.4和2.5的两个版本,可以根据你的版本下载,今天是在linux下,所以直接下载source版本就可以了。目前的版本号是Twisted-8.1.0
2、安装Twisted
下载好Twisted后,进入到下载目录,解压:
Continue reading Linux下Python网络编程框架-Twisted安装手记 - 全文阅读

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • MySpace
  • RSS
  • Slashdot
  • Technorati
  • TwitThis

序列、元组、列表、字典

# 序列: 在 里,元组,列表,字符串都称作序列,都可以进行切片操作.
# 元组(): 一组不可修改的元素的集合
# 列表[]: 一组可以任意修改的元素的集合
# 字典{}: 一组具有索引的可变的元素的集合
Continue reading 序列、元组、列表、字典 - 全文阅读

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • MySpace
  • RSS
  • Slashdot
  • Technorati
  • TwitThis

Universal Encoding Detector

http://chardet.feedparser.org/
http://chardet.feedparser.org/docs/how-it-works.html
参考:http://www.mozilla.org/projects/intl/UniversalCharsetDetection.html

Basic usage

The easiest way to use the Universal Encoding Detector library is with the detect function.

Continue reading Universal Encoding Detector - 全文阅读

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • MySpace
  • RSS
  • Slashdot
  • Technorati
  • TwitThis

URL 调度程序

对高质量的 WEB 应用程序来说, 有一个干净优雅的 URL 调度机制是至关重要的. Django 允许你根据需要设计 URLs ,没有任何框架层的限制.

不需要 .php 或 .cgi 扩展名, 也没有象 0,2097,1-1-1928,00 那样的丑陋东西.

参阅 WWW 的缔造者 Tim Berners-Lee 所写的 Cool URIs don’t change, 这篇文章的主题就是为什么 URL 应该是干净并且便于使用的.

1   概述

要为一个应用程序设计 URLs, 要生成一个称为 URLconf (URL 配置) 的非正式的 模块. 该模块为纯 代码, 它的作用就是在 URL 模式(简单的正则表达式)及 回调函数( 你的 views) 之间建立映射.

这个映射根本需要可以很短,也可以很长. 它能够引用其它的映射. 由于是纯 代码, 就有能力动态的创建这种映射.

Continue reading URL 调度程序 - 全文阅读

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • MySpace
  • RSS
  • Slashdot
  • Technorati
  • TwitThis

python range()函数的用法

在以往用range函数的时候从未深入的了解过,只是简单的这样用,而从未去想其他的

>>> range(1,5) #两个参数的,从1到5
[1, 2, 3, 4]
>>> range(1,5,2) #三个参数的,从1到5,间隔数字为2,所以显示奇数
[1, 3]
>>> range(5) #一个参数的,默认start是从0开始,end是5
[0, 1, 2, 3, 4]

今天看《核心编程》第二版中,在讲切片时,作者举了一个例子:“有这么一个问题:有一个字符串,我们想通过一个循环按照这样的形式显示它:每次都把位于最后的一个字符砍掉”,这个例子虽然很小,也很简单
Continue reading python range()函数的用法 - 全文阅读

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • MySpace
  • RSS
  • Slashdot
  • Technorati
  • TwitThis

Python 3.1.1 RC发布

是一门跨平台的脚本语言,规定了一个语法规则,实现了语法的解释程序就成为了的解释器,我 们用的比较多的是C版本的,也就是使用C语言实现的解释器,除此之外还有使用Java实现的Jython和使用.NET实现的 IronPython,这些实现可以使用户充分利用己有的Java及.NET资源.

The 3.1.1 release candidate was released on August 13th, 2009.

3.1 is a continuation of the work started by 3.0, the new backwards-incompatible series of . Improvements in this release include:
Continue reading Python 3.1.1 RC发布 - 全文阅读

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • MySpace
  • RSS
  • Slashdot
  • Technorati
  • TwitThis

py2exe,生成可执行文件.

py2exe,用脚本生成可执行文件
Py2exe 官网:
http://www.py2exe.org/

先要写一个setup的脚本,格式如下:

#!/usr/bin/env 

from distutils.core import setup

setup(name=’Distutils’,
      version=’1.0′,
      description=’ Distribution Utilities’,
      author=’Greg Ward’,
      author_email=’gward@python.net‘,
      url=’http://www.python.org/sigs/distutils-sig/’,
      packages=['distutils', 'distutils.command'],
     )
假设你准备转换的脚本保存为myscript.py 

然后写setup.py,内容如下:

# setup.py
from distutils.core import setup
import py2exe

setup(console=["myscript.py"])
如果你想要在你的py程序运行时候不在别后显示讨厌的shell黑框,你只要把console=["myscript.py"] 替换成windows=["myscript.py"].

然后在shell当中运行如下内容:

 setup.py py2exe
OK,exe程序轻松搞定。

来点复杂的:
如果你想把你的py程序注册成为windows nt的服务程序。只要把脚本修改成如下就可以了:

# setup.py
from distutils.core import setup
import py2exe

setup(service=["MyService"]) http://hi.baidu.com/webtalk/blog/item/2f0d0708f01572d163d9863c.html

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • MySpace
  • RSS
  • Slashdot
  • Technorati
  • TwitThis

Python 字符串方法详解

在编程中,几乎90% 以上的代码都是关于整数或字符串操作,所以与整数一样,
的字符串实现也使用了许多拿优化技术,使得字符串的性能达到极致。与 C++ 标准库(STL)中的 std::string 不同,
字符串集合了许多字符串相关的算法,以方法成员的方式提供接口,使用起来非常方便。 字符串方法大约有几十个,这些方法可以分为如下几类(根据 manuals 整理):

Continue reading Python 字符串方法详解 - 全文阅读

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • MySpace
  • RSS
  • Slashdot
  • Technorati
  • TwitThis

Python Imaging Library (PIL)

puppies-img_0254 The Imaging Library (PIL) adds processing capabilities to your interpreter. This library supports many file formats, and provides powerful processing and graphics capabilities.

Status

The current free version is PIL 1.1.6. This release supports 1.5.2 and newer, including 2.4 and 2.5.

 

More: http://www.pythonware.com/products/pil/

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • MySpace
  • RSS
  • Slashdot
  • Technorati
  • TwitThis
 Page 6 of 10  « First  ... « 4  5  6  7  8 » ...  Last » 

Contact us

Admin: Bryan Wu