Python : Use dictionary to simulate multi-dimension array
Since there is no array in Python. Use dictionary instead. Follows are the example to initialize a 2x2 array >>>a={} >>>for i in range(4): . . . a[i/2, i%2] = i >>> a { (0,1):1, (1,0):2, (0,0):0, (1,1):3 } >>>a[0,1] 1
沒有留言:
張貼留言