易截截图软件、单文件、免安装、纯绿色、仅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学习笔记

type相关:
所有自定义类A
其实例,如 a = A()
使用type运算符返回的都是<type, 'instance'>
而基本类型
比如 b = 3
type(b),结果是<type, 'int'>
python的type不像C++中的typeid那样,可以显示类名。
(注:对于没有virtual函数的类而言,typeid是编译时期的事情(也就是静态类型);对于有virtual函 ......

python天天进步(2) 文件操作之遍历目录

 
Python的os模块,包含了普遍的操作系统功能,这里主要学习与路径相关的函数:
os.listdir(dirname):列出dirname下的目录和文件
os.getcwd():获得当前工作目录
os.curdir:返回当前目录('.')
os.chdir(dirname):改变工作目录到dirname
os.path.isdir(name):判断name是不是一个目录,name不是目录就返回false ......

Linux下用PYTHON查找同名进程

1.可执行程序
os.system('pgrep %s > %s' % (process, output))
   pidfile = open("output", 'r')
   totalpid = len(pidfile.readlines())
   pidfile.close()
   if totalpid == 0 :
         &nbs ......

[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, c#, java写的文件拷贝

     前一段时间试着用这三种语言简单的写了关于文件拷贝的程序,发现c#和python的api惊人的相似,对于文件的操作这两种语言非常的方便。都没有加异常的处理
C#源代码:
        public static void CopyFile(string source, string destination)
  & ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号