-1

I have following lines

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

What does r and ! mean here?

Tany
  • 393
  • 1
  • 4
  • 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,986
  • 6
  • 44
  • 71
0

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

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358