Python - 将格式字符串转换为 f 字符串

Python - convert format string to f-string

如何将其转换为 f 字符串?

message = '{status} : {method} : {url}'.format(**call_components)

str.format() 通常没问题,但如果你真的想要一个 f-string 那么它看起来像这样: message = f'{call_components["status"]} : {call_components["method"]} : {call_components["url"]}'