0

I have have the following strings

s1 = "/url/{part}"
s2 = "/url/{code}"

How can I extract the named arguments from the above strings, and get part and code?

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
user1187968
  • 7,154
  • 16
  • 81
  • 152
  • 2
    A regular expression that matches everything from `{` to `}` would be a simple way to do it. – Barmar Mar 05 '21 at 19:57
  • Just for fun, see https://repl.it/@JustinEzequiel/EnchantingUpbeatLinuxpc for an alternative that uses `str.format` and catches the `KeyError`. Not recommended for production use. –  Mar 05 '21 at 20:13

0 Answers0