今天爱分享给大家带来Python中列表的append和extend的区别【面试题详解】,希望能够帮助到大家。
>>> x = [1, 2] >>> x.append(3) >>> x [1, 2, 3] >>> x.append([4,5]) >>> x [1, 2, 3, [4, 5]] >>> >>> x = [1, 2, 3] >>> x.extend([4, 5]) >>> x [1, 2, 3, 4, 5]
原文链接:https://blog.itblood.com/4440.html,转载请注明出处。

![流星猎犬/hounds of the meteor[Ver.20250810][PC/10.6G] [ACT/官中/全动态/更新/3D]](/wp-content/uploads/replace/2025/09/02/93e2550c0af937ff3fd1ded95882254e.webp)