-1

I have following lines

{value!r}".format(value=value) 
%(access_token)r % value

What does r and ! mean here?

Tany
  • 373
  • 1
  • 3
  • 16

2 Answers2

1

It's a conversion operation. It converts value to a string using repr()

Check out "Explicit Conversion Flag" in https://www.python.org/dev/peps/pep-3101/ for more info.

Ben
  • 6,395
  • 6
  • 38
  • 67
0

r means print the repr() of the object. ! is what allows it to work in format strings.

Ignacio Vazquez-Abrams
  • 740,318
  • 145
  • 1,296
  • 1,325