易截截图软件、单文件、免安装、纯绿色、仅160KB

关于Python正则表达式的区分大小写的问题

最近在用Python处理一些数据,数据需要存储到MySQL数据库中,采用MySQLdb来进行数据库的操作,但是被一个问题困扰了很久。在打开数据库的时候MySQLdb.connect(self.host, self.user, self.password, self.database, port=self.port)出异常,而且异常出现的位置非常奇怪。
出现在converters.py 164行
from decimal import Decimal
进去之后发现出错的位置在decimal.py文件中5833行出错
import re
_parser = re.compile(r"""        # A numeric string consists of:
#    \s*
    (?P<sign>[-+])?              # an optional sign, followed by either...
    (
        (?=\d|\.\d)              # ...a number (with at least one digit)
        (?P<int>\d*)             # having a (possibly empty) integer part
        (\.(?P<frac>\d*))?       # followed by an optional fractional part
        (E(?P<exp>[-+]?\d+))?    # followed by an optional exponent, or...
    |
        Inf(inity)?              # ...an infinity, or...
    |
        (?P<signal>s)?           # ...an (optionally signaling)
        NaN                      # NaN
        (?P<diag>\d*)            # with


相关文档:

python enumerate用法

python cookbook  
Recipe 2.5. Counting Lines in a File

     今日发现一个新函数
enumerate
。一般情况下对一个列表或数组既要遍历索引又要遍历元素时,会这样写:

for
i
in
range
(0
,
len
(list
)):

 &n ......

UBUNTU10.04安装stackless python运行高性能服务器

以下"#"开头是Ubuntu终端命令
1。首先安装Ubuntu10.04
参考 http://wiki.ubuntu.org.cn/
2。修改root用户密码
3。使用root登陆系统
 
4。Ubuntu默认已经安装python2.6.5
 
5。下载stackless
查看网址 http://zope.stackless.com/download/sdocument_view
# cd /usr/src
# wget http://www.sta ......

Python为类定义“拷贝构造函数”

初学Python,这么做好像有点2,凑合能用:
class MyClass():
def __init__(self, n = 10):
self._Field = n
def __getitem__(self, range):
return MyClass(self._Field)
obj1 = MyClass()
obj2 = obj1
obj3 = obj1[:]
obj1._Field = 100
obj4 = MyClass(123)
print obj1._Field, obj2. ......

Python标准库的threading.Thread类

这个类表示在单独的控制线程中运行的活动。有两种方法可以指定这种活动,给构造函数传递回调对象,或者在子类中重写run() 方法。其他方法(除了构造函数)都不应在子类中被重写。换句话说,在子类中只有__init__()和run()方法被重写。
一旦线程对象被创建,它的活动需要通过调用线程的start()方法来启动。这方法再调用控制 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号