是否可以在fstring中创建fstring?
我现在正在尝试使用eval创建动态函数。
我的代码是这样的
$select = $con ->prepare("SELECT name from table WHERE name NOT IN ('".implode('","',$array)."') AND ageNOT IN ($rrt) GROUP BY name ");
$select -> execute($ees);
运行此脚本将返回: 这是part1
答案 0 :(得分:1)
您可以创建这样的工厂方法...
def factory(a, b):
def g(c):
print(f'this is {c}')
return f'other stuff using {a}, {b} and {c}' # if you want to
return g
然后像使用它
>>> f = factory('scene1', 'int')
>>> msg = f('part1')
this is part1
>>> print(msg)
other stuff using scene1, int and part1