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.
リストできますか
mylist = ['a',1,2,'b',3,4,'c',5,6]
辞書を作成するために使用されます
mydict = {'a':(1,2),'b':(3,4),'c':(5,6)}
キーとなる何らかの基準がある場合のみ。文字列がキーの場合:
d = {} key = None for item in my_list: if isinstance(item, str): key = item else: d.setdefault(key, []).append(item)