标签:
1 >>> li = [‘a‘, ‘b‘, ‘c‘] 2 >>> li.extend([‘d‘, ‘e‘, ‘f‘]) 3 >>> li 4 [‘a‘, ‘b‘, ‘c‘, ‘d‘, ‘e‘, ‘f‘] 5 >>> len(li) 6 6 7 >>> li[-1] 8 ‘f‘ 9 >>> li = [‘a‘, ‘b‘, ‘c‘] 10 >>> li.append([‘d‘, ‘e‘, ‘f‘]) 11 >>> li 12 [‘a‘, ‘b‘, ‘c‘, [‘d‘, ‘e‘, ‘f‘]] 13 >>> len(li) 14 4 15 >>> li[-1] 16 [‘d‘, ‘e‘, ‘f‘]
python: extend (扩展) 与 append (追加) 的差别
标签:
原文地址:http://www.cnblogs.com/testlife007/p/4895561.html