我以为我理解了python的传递引用处理......为什么列表的传递引用与列表元素的传递引用之间存在差异,特别是据我所知,如果两者都是对象:
dataBloc = [ ['123'] , ['345'] ]
print dataBloc
def func( b ):
print ( 'Row-by-Row Before' , b )
for row in b:
row = [ float(x) for x in row ]
print ( 'Row-by-Row After' , b )
print ( 'Element-by-Element Before' , b )
for row in b:
for i in range(len(row)):
row[i] = float(row[i])
print ( 'Element-by-Element After' , b )
return b
print func(dataBloc)
[['123'], ['345']]
('Row-by-Row Before', [['123'], ['345']])
('Row-by-Row After', [['123'], ['345']])
('Element-by-Element Before', [['123'], ['345']])
('Element-by-Element After', [[123.0], [345.0]])
[[123.0], [345.0]]
谢谢。