新手求助,两个问题,望大佬解答,感谢
1,若有 l1 = [2,3,4],试说明下面两个语句有何不同。 l2 = l1 l2 = l1[:]?2,说明表达式2*['a']+['c']*3的值,解释该表达式用到哪些列表操作?
l1 = [2,3,4] l2 = l1 l3 = l1[:] print(f'l1:{id(l1)}') print(f'l2:{id(l2)}') print(f'l3:{id(l3)}')
l1 = [2,3,4] l2 = l1 l3 = l1[:] print(l2) print(l3) print('----') l1[1] = 10 print(l2) print(l3)