我试图运行一条SQL语句,由Affaiw呈现,但我也试图在该语句中包含一个从Python传入的变量。SQL语句只是一个where子句,在WHERE
之后,我试图添加一个datetime,减去几秒钟:
f" ' {{ ts - macros.timedelta(seconds={lower_delay} + 1) }} ' "
所以我想计算双大括号中的内容并在气流中渲染,但我想在它执行此操作之前传入名为lower_delay
的变量。我尝试过在lower_delay
和整个字符串周围使用零、一或两个额外的大括号进行不同的组合,但每次似乎都会出现不同的错误
传递这个lower_delay
变量(它只是一个数字)的正确方法是什么
Jinja模板需要两个大括号,当您使用f-strings或str.format时,它将在渲染时用一个大括号替换两个大括号:
因此,以下措施应该有效:
相关问题 更多 >
编程相关推荐