此问题已在此处有答案:
How do I escape curly-brace ({}) characters in a string while using .format (or an f-string)?(23答案)
3天前关闭。
由于Hourly Status','{',''),'}','')
中的这些括号{
和}
导致查询中的语法错误。如何以f字符串格式将这些括号作为字符串传递?
query = f"""Select fd.serial_number,txidkey,cast(replace(replace(data->>'Hourly Status','{',''),'}','') as text) as description,TO_TIMESTAMP(TIME/1000+19800) as date_time,time,total_min from filter_data fd , total_sum ts
where fd.serial_number = ts.serial_number
and time between {yesterday10PM*1000} and {today6AM*1000}'''
1条答案
按热度按时间wwtsj6pe1#
使用双花括号
{{
:你也可以在这里阅读格式化的字符串:
https://docs.python.org/3/reference/lexical_analysis.html#formatted-string-literals