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() ##µ÷Óú¯Êý¶ÔÏó
Ïà¹ØÎĵµ£º
¶þ½øÖÆÎļþÏÂÔØµØÖ·£º
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 ......
żȻÐèÒªÓõ½ÕâÑùÒ»¸öº¯Êý£¬ÔÚDelphiÖУ¬ÓÐÏֳɵĺ¯Êý¿ÉÒÔµ÷Óã¡ÔÚpythonÖУ¬ÎÒÕÒÁ˰ëÌì¶¼»¹Ã»ÕÒµ½£¬×îºó×Ô¼ºÐ´ÁËÒ»¸öº¯ÊýÈçÏ£º
def dayOfMonth(date):
if date.month == 12:
return 31
else:
return (date.replace(month=date.month+1, day=1) - datetime.timedelta(days=1)).day
......
µ±½ñÓÐÐí¶àÃâ·ÑµÄ RDBMS£¨Relational Database Management
System£¬¹ØÏµÊý¾Ý¿â¹ÜÀíϵͳ£©£¬ÆäÖÐһЩÊÇ¿ª·ÅÔ´ÂëÈí¼þ£¬ÁíһЩÊÇÉÌÒµ³§ÉÌÌṩµÄÃâ·Ñ²úÆ·¡£Èç¹ûÄúÕýÔÚʹÓà C/C++¡¢Java™¡¢.NET
»ò PHP
¿ª·¢Ó¦ÓóÌÐò£¬ÏëѰÕÒÒ»ÖÖ¿É¿¿µÄÊý¾Ý·þÎñÆ÷£¬Ï£ÍûËüÖ§³ÖÏȽøµÄ¼¼Êõ¡¢¾ßÓв»¶ÏÀ©´óµÄ¿ª·¢ÈËÔ±ÉçÇø²¢ÒѾ²¿ÊðÔÚÐí¶à¹Ø¼ ......
ѧϰpython±¾¾ÍÊÇÒµÓàÖ®ºÃ£¡Ê鱾ɶµÄ£¬¶¼ÎÞ´Ó˵Æð¡£ËùÒÔż¶ûÅöµ½Ò»¸öºÃµÄÄ£¿é£¬¾ÍÒªÔÚ²©¿ÍÖмǼһÏ£¬ÒÔ±ãÈÕºóÖ®Óá£ÊÇÒÔ¸ßÊÖÖ±½ÓµÄÆ®¹ý¡£ÏÂÃæÇÐÈëÕýÌâ¡£
globÊÇpython×Ô¼º´øµÄÒ»¸öÎļþ²Ù×÷Ïà¹ØÄ£¿é£¬ÄÚÈÝÒ²²»¶à£¬ÓÃËü¿ÉÒÔ²éÕÒ·ûºÏ×Ô¼ºÄ¿µÄµÄÎļþ£¬¾ÍÀàËÆÓÚWindowsϵÄÎļþËÑË÷£¬¶øÇÒÒ²Ö§³ÖͨÅä·û£¬*,?,[]Õ ......