# 匿名函数:lambda表达式
# lambda 参数: 逻辑
f = lambda name: print(name)
f('tom')
f2 = lambda x, y: x + y
print(f2(4, 6))
# 实现根据输入的筛选条件执行不同的函数
def hello_chinese(name):
print('你好', name)
def hello_english(name):
print('hello', name)
operation = {
'c': hello_chinese,
'e': hello_english,
'j': lambda name: print('こんにちは', name)
}
while True:
name = input('请输入名字:')
if name == 'stop':
break
language = input('请选择语言:
c ==> 中文
e ==> 英文
j ==> 日文')
operation.get(language, hello_chinese)(name) # 输入的值不为cej时,默认调hello_chinese