函数如下:
function ChangeWord($keyword, $value, $changfun) {
return is_callable($changfun) ? call_user_func($changfun, $keyword, $value) : $changfun;
}
函数如下:
function ChangeWord($keyword, $value, $changfun) {
return is_callable($changfun) ? call_user_func($changfun, $keyword, $value) : $changfun;
}
import types
import sys
def change_word(keyword, value, change_func):
if callable(change_func):
return change_func(keyword, value)
else:
return change_func
def test(keyword, value):
print keyword
print value
if __name__ == '__main__':
change_word('hello', 'world', test)
change_word('goodbye', 'world', lambda keyword,value: sys.stdout.write('%s, %s' % (keyword, value)))
已抢186145个
抢已抢67103个
抢已抢352667个
抢已抢666665个
抢已抢121426个
抢已抢22358个
抢