[Solved] how to print a string who contains variables, the string is contained is .json file? [closed]


I think you should develop more on your fundamentals, and try out your own code before asking a question here.

I guess what you are trying to achieve can be done like this.

import json

with open("example.json", "r") as f:
   json_content = json.load(f)

message = json_content["message"]
variable = "var"
print(message.format(variable=variable))

# prints
# this is a message with a var

0

solved how to print a string who contains variables, the string is contained is .json file? [closed]