Search code examples
pythonpython-3.xf-string

Python - convert format string to f-string


How can I convert this to an f-string?

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

Solution

  • str.format() is usually fine, but if you really want an f-string then it would look like this: message = f'{call_components["status"]} : {call_components["method"]} : {call_components["url"]}'