靜態方法的實現

2021-04-25 16:07:09 字數 633 閱讀 6558

python 2.2中(對於新舊**同樣適用),新的內建staticmethod函式封裝了對於靜態函式的呼叫,只需要在類作用域範圍內幫定相應函式名稱到對應的靜態函式。     class greeter:

def greet(name): print "hello", name

####################################

greet = staticmethod(greet)

####################################

#in python 2.1 and earlier, we can easily simulate the same construct:

#python 2.1及早期版本中,可以如下處理,達到相同效果:

class staticmethod:

def _ _init_ _(self, anycallable): self._ _call_ _ = anycallable

>>> greeting = greeter(  )

>>> greeting.greet("peter")

hello peter

>>> greeter.greet("paul")

hello paul

偽靜態的實現方法

偽靜態不是優化效率的方案,它指的是url優化的一種方式。取決於是否存在查詢引數 querystring 動態的url script.php?param value key value 靜態的url pathinfo script.php param value key value.html 靜態化u...

偽靜態的實現方法

偽靜態不是優化效率的方案,它指的是url優化的一種方式。取決於是否存在查詢引數 querystring 動態的url script.php?param value key value 靜態的url pathinfo script.php param value key value.html 靜態化u...

關於偽靜態的實現方法

php怎麼實現呢,具體方法如下 apache伺服器 利用apache的mod rewrite模組 1.檢測apache是否支援 mod rewrite 開啟您的apache安裝目錄 apache conf 下的 httpd.conf 檔案,通過ctrl f查詢到 loadmodule rewrite...