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

python decorator

1.常用方法,不带参数
def decator(func):
    def inner_func(*args):
        args = (i * 2 for i in args)
        return func(*args)
    return inner_func
   
@decator
def add(a, b, c):
    return a + b + c
2.带参数:
class Dec(object):
    def __init__(self, i):
        self.i = i
    def __call__(self, func):
        def inner_func(a, b, c):
            return self.i * func(a, b, c)
        return inner_func
   
@Dec(2)
def abc(x, y, z):
    print "function abc"
    print (x, y, z)
    return x + y + z


相关文档:

python 数据库

def Start(self):
        if (self.conn == None) or (self.conn.State == 1):
            self.conn = win32com.client.Dispatch(r'ADODB.Connection')
          &n ......

[Python module] select

16.1. select — Waiting for I/O completion¶
This module provides access to the select and poll functions available in most operating systems, epoll available on Linux 2.5+ and kqueue available on most BSD. Note that on Windows, it only works for sockets; on other operating systems, it al ......

[Python module] threading

threading — Higher-level threading interface
This module constructs higher-level threading interfaces on top of the lower level _thread module. See also the queue module.
The dummy_threading module is provided for situations where threading cannot be used because _thread is missing.
  ......

Python: python的简单表达式计算器

这是一个简单的表达式计算器, 不太懂用Tkinter写GUI, 参考了别人的代码
from __future__ import division
from Tkinter import Tk, Entry, Button, Label, mainloop
from tkFont import Font
def get_value ():
v = ''
try:
v = eval(text.get()) #use eval to calculate the vlaue of the text
except:
pa ......

[转]Python: python编码问题

这是一个我们在处理中文时, 经常遇到的问题.
python里面基本上要考虑三种编码格式
1 源文件编码
在文件头部使用coding声明。告诉python解释器该代码文件所使用的字符集。
#/usr/bin/python
#coding: utf8
2 内部编码
代码文件中的字符串,经过decode以后,被转换为统一的unicode格式的内部数据,类似于u'*'。unic ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号