11

The following code:

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

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

cs95
  • 330,695
  • 80
  • 606
  • 657
petrush
  • 885
  • 7
  • 20

1 Answers1

12

Escape the braces like this.

>>> f'{{"c": {a}}}'
'{"c": 0}'
cs95
  • 330,695
  • 80
  • 606
  • 657