0

I have the following command I need to send to a device console:

abcd '{ "aa" : "bb" ,"cc" : "{}", "ff": {"ee" : "{}", "dynamic_multicast_rate" : "{}" }}'

I want to replace only {} using format(var1, var2, var3) I was not able to normally achieve it.

Barmar
  • 741,623
  • 53
  • 500
  • 612
Sion C
  • 439
  • 2
  • 14
  • 3
    if you want to build a json string, i'd recommend looking into the `json` module. You can then just turn a dict into a string, `json.dumps({"aa": "bb", "cc": var1})` etc – Talon May 05 '20 at 20:26
  • Try working with a dictionary instead of a string, you can also use an f-string but you have to escape the curly braces `{` and `}` with a `\ ` like: `abcd = f'\{ "aa" : "bb" ,"cc" : "{var1}", "ff": \{"ee" : "{var2}", "dynamic_multicast_rate" : "{var3}" \}\}'` but that's messy – bherbruck May 05 '20 at 21:05

0 Answers0