Case 1. type(x)
Copy
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
Copy
a = [
10
,
20
,
30
,
40
]
>>>
isinstance
(a,
list
)
True
>>>
isinstance
(a,
dict
)
False
Copy
b = {}
b[
"
one
"
] =
10
b[
"
two
"
] =
20
b[
"
three
"
] =
30
b[
"
four
"
] =
40
>>>
isinstance
(b,
dict
)
True
>>>
isinstance
(b,
list
)
False
Python
dict
list
Retrieved from https://hyacinth.kr:443/moniwiki/wiki.php/Python/list인지 dict인지 판단
last modified 2022-03-16 20:32:09