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

Python 中的函数调用(类似c中的使用函数入口地址)

def login():
    print 'login'
def logout():
    print 'logout'
controllers = {
'in': login,                                                ##(类似c中的:使用函数入口地址作为字典的值)
'out':logout,
}
def dispatcher(url, controllers):
    func = controllers.get(url, None)         ##(类似c中的:将函数入口指针赋给func)
    if func:
        func()                                              ##(类似c中的:这里通过函数入口指针调用函数)
    else:
        print 'Wrong url!'
dispatcher('in',controllers)
dispatcher('out',controllers)
dispatcher('23',controllers)
结果 :
login
logout
Wrong url!
 ---------------------------------------------------------------------------------------------------------
Python中函数是个对象,所以也是和其他对象一样的使用。
def f1():   ##声明了一个函数对象
    pass
a=f1        ##把函数对象f1赋给a
print a
print f1    ##结果相同 (都指向同一个地址)
f1()         ##调用函数对象
a()          ##调用函数对象


相关文档:

Python嵌入C++详解(3)

继前篇《Import Module》(http://blog.csdn.net/xiadasong007/archive/2009/09/02/4512797.aspx),继续分析嵌入部分基础知识。这次不多说,有什么问题记得多查英文资料,国内的这方面知识少
还是来看代码,写完我就睡觉了~
 
#include "python/python.h"
#include <iostream>
using namespace std;
int ......

Delphi 与 C/C++ 数据类型对照表

Delphi 与 C/C++ 数据类型对照表
Delphi数据类型C/C++
ShorInt
8位有符号整数
char
Byte
8位无符号整数
BYTE,unsigned short
SmallInt
16位有符号整数
short
Word
16位无符号整数
unsigned short
Integer,LongInt
32位有符号整数
int,long
Cardinal,LongWord/DWORD
32位无符号整数
unsigned long
Int6 ......

python中的列表排序操作

 
 
 
Python lists have a built-in sort() method that modifies the list in-place and a sorted() built-in function that builds a new sorted list from an iterable.
There are many ways to use them to sort data and there doesn't appear to be a single, central place in the various man ......

Python笔记(7)

  一个Python脚本的开发全过程
问题:完成一个可以为我们所有的重要程序做备份的程序。
步骤拆解:
需要备份的文件和目录由一个列表指定。
文件备份成一个zip文件。
zip存档的名称是当前的日期和时间。
我们使用标准的zip命令,它通常默认地随Linux/Unix发行版提供。Windows用户可以使用Info-Zip程序。注意 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号