Curly braces with f-strings - ValueError: Sign not allowed in string format specifier

Viewed 10617

The following code:

a = 0
b = f'{"c": {a}}'

throws the error: ValueError: Sign not allowed in string format specifier How to fix it?

1 Answers

Escape the braces like this.

>>> f'{{"c": {a}}}'
'{"c": 0}'
Related