Python lambdaの使い方

814 ワード

Lambdaは単一の式しか接続できません.
#!/usr/bin/python
#coding=gbk

#
def make_repeater(n):
    return lambda s: s*n

def inter_up(k):
    return lambda s: s+k

twice=make_repeater(2)
twice2=inter_up('word')

print twice2('hello,')
print twice('hello')
print twice(10)