rank vote view answer url
14 2787 2286116 24 url

Python中的appen和extend

appendextend有什么区别?


append:

x = [1, 2, 3]
x.append([4, 5])
print (x)

输出:[1, 2, 3, [4, 5]]

extend:

x = [1, 2, 3]
x.extend([4, 5])
print (x)

输出:[1, 2, 3, 4, 5]

Copyright © taizilongxu 2018 all right reserved,powered by Gitbook该文件修订时间: 2018-10-17 17:33:54

results matching ""

    No results matching ""