Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
オブジェクトが Python でtype(obj)-->を使用してリストであるかどうかを検出できる方法はありますかlist?
type(obj)
list
しかし、オブジェクトが次のような形式のリストのリストであるかどうかをどのように検出できますか:
[['a','b']['a','b'][][]]
リスト内のすべてのアイテムがリストであることを確認したい場合は、次のようにすることができます。
if all(isinstance(i, list) for i in lst): # All of the items are lists
isinstance(i, list)
type(i) == type(list)
type(i) == list)
all()
True
False