我有一个嵌套的词典:
KEYS1 = ("A", "B", "C")
KEYS2 = ("X", "Y", "Z")
d = dict.fromkeys(KEYS1, dict.fromkeys(KEYS2, 0))
Run Code Online (Sandbox Code Playgroud)
我现在想要使用格式将其值嵌入到字符串中,例如
print("d['A']['X']={A,X:d}".format(**d))
Run Code Online (Sandbox Code Playgroud)
输出:
d['A']['X']=0
Run Code Online (Sandbox Code Playgroud)
这不起作用.有关如何正确执行此操作的任何建议?
python ×1