易截截图软件、单文件、免安装、纯绿色、仅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 抓取新浪读书频道小说

二进制文件下载地址:
SinaGetBook
效果如图:
代码:
#!/usr/bin/env python
#coding=utf-8
#!/usr/bin/env python
#coding=utf-8
import traceback
import sys
import wx
import re
import urllib
import wx.richtext as rt
import wx.lib.buttonpanel as bp
import Casing
import Debug
def trace_back ......

(转) python应用领域介绍

#---------------------转转转转转转转转转转转转转转转转转转转转转转转-------------------------------------------#
Python作为一种功能强大且通用的编程语言而广受好评,它具有非常清晰的语法特点,适用于多种操作系统,目前在国际上非常流行,正在得到越来越多的应用。
 
  下面就让我们一起来看看它的强大 ......

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的wiki 列子.

#coding=utf-8
from newtest.wiki.models import WiKi
from django.template import loader, Context
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response

def index(request, pagename=""):
"""显示正常页面,对页面的文字做特殊的链接处理"""
......

Python 定时运行脚本

import sys
import os
import datetime
import time
class ArgsDealwith:
   
    def arg_environment(self, args):
        filepath = ('PYTHON_PATH', 'path')
        for i in filepath:
 &nbs ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号