def _product_of_two_vectors_sample_(a, b): if len(a[0]) != len(b): return None # Create the result matrix and fill it with zeros output_list=[] temp_row=len(b[0])*[0] for r in range(len(a)):
作者: LiloHuang (十年一刻) 2016-03-27 11:25:00
temp_row[:] 会做出一份拷贝,反之则是参照原先的list>>> foo = [1,2,3]>>> id(foo)33920784>>> bar = foo>>> id(bar)33920784>>> bar = foo[:]>>> id(bar)33919424留意到了 object id 改变了吗 :P