需求
因为python中的字典和json中的一些变量有差异,比如:json中有null、true,在python中就不会被识别,只能转换成字符串,在通过loads()的方式转成python的字典。
在把json定义成字符串后,需要动态的传递一些参数,如下面这个例子:
if __name__ == '__main__':
# tkn = util_tools.get_api_tkn()
# template_api = ArchCategoryApi(tkn)
# res = template_api.get_template_list()
# print(res)
json_template = '{"name": "{}", "age": "{}", "city": "{}"}'
# 参数列表
name = "Alice"
age