如何檢查變量是否是Python中的字典?

| |

如何檢查一個變量是否是 Python 中的字典?

例如,我希望它循環遍歷字典中的值,直到找到字典。然後,循環遍歷它找到的一個:

dict = {"abc": "abc", "def": {"ghi": "ghi", "jkl ": "jkl"}} for k, v in dict.iteritems(): if ###check if v is a dictionary: for k, v in v.iteritems(): print(k, " ", v) else : 打印(k, " ", v)