に新しい項目を追加するたびにする方法:新しいオブジェクトに私はだから私はこのような問題が持っているリストのpython
if array_of_things[1][1] == True: #If the second item in list is bumpy
print("The second item is bumpy")
:アイテムにアクセスするには
array_of_things = [[is_shiny=False, is_bumpy=True]
[is_shiny=False, is_bumpy=False]
[is_shiny=True, is_bumpy=True]]
を、私はこれを行うだろう
はしかし、私のコードをより明確にするために、私は、配列内の各アイテムは次のようにアクセスできるようにしたい:
if array_of_things[1].is_bumpy == True: #If the second item in the list is bumpy
print("The second item is bumpy")
私はそれをどのように行うことができますか?どんな助けもありがとう。
外部リストのリストの代わりに辞書オブジェクトを使用すると考えましたか? – dunkmann00
注文する場合は、OrderedDictを使用することができます。 namedtupleも見てください。 –