本文實例講述了python創建關聯數組(字典)的方法。分享給大家供大家參考。具體分析如下:
關聯數組在python中叫字典,非常有用,下面是定義字典的兩種方法
# Dictionary with quoted or variable keysd1 = {"name":"donuts","type":"chocolate","quantity":10}# Dictionary with fixed keysd2 = dict(name="donuts",type="chocolate",quantity=10)assert d1 == d2
希望本文所述對大家的Python程序設計有所幫助。
新聞熱點
疑難解答