Case 1. type(x)
a = [10, 20, 30, 40]
>>> type(a)
<class 'list'>
>>> type(a) is list
True
>>> type(a) is dict
False
>>> type(a).__name__
list

Case 2. isinstance
a = [10, 20, 30, 40]
>>> isinstance(a, list)
True
>>> isinstance(a, dict)
False
b = {}
b["one"] = 10
b["two"] = 20
b["three"] = 30
b["four"] = 40
>>> isinstance(b, dict)
True
>>> isinstance(b, list)
False


Retrieved from http://hyacinth.byus.net/moniwiki/wiki.php/Python/list인지 dict인지 판단
last modified 2022-03-16 20:32:09