python two-dimensional array assignment initialize

#if you want to initialize a 9*9 two-dimensional array 

[([""]*9) for i in range(9)]



#caution:  the follow code can't work 
[[""]*9]*9

shallow copies of list concatenated 

if you change one row then the prefix row will also be changed

 

posted @ 2015-12-20 11:37  hao.ma  阅读(327)  评论(0编辑  收藏  举报