再简单的代码也要亲手敲一遍
Topic source借鉴了一下
from math import sqrt
def do_sth(x=[],*func):
return [f(x_k) for x_k in x for f in func]
print(do_sth([1,2,4,9],abs,sqrt))
借鉴了一下
from math import sqrt
def do_sth(x=[],*func):
return [f(x_k) for x_k in x for f in func]
print(do_sth([1,2,4,9],abs,sqrt))
翁岚敏
来一个可变参数,要几个函数就来几个
from math import sqrt def same(x,*fs): s=[f(x) for f in fs] return s print(same(2,sqrt,abs))