12 2021 档案

摘要:一道很基础的题目,核心考点:拼接列表 涉及到的知识点: 1、Python列表拼接的三种方式: List_A+List_B 切片赋值 extend() 2、切片赋值的用法(从无到有进行了学习) 3、extend()返回None的原因 4、三种用法的好坏(耗时、占用内存)(i->最优) 阅读全文
posted @ 2021-12-29 18:12 MoKin_Li 阅读(26) 评论(0) 推荐(0) 编辑
摘要:问题代码: class Solution(): def getConcatenation(self, nums): print(nums.extend(nums)) A = Solution() A.getConcatenation([1, 2, 3]) 代码最后的回显为: [1, 2, 3] No 阅读全文
posted @ 2021-12-29 18:06 MoKin_Li 阅读(49) 评论(0) 推荐(0) 编辑
摘要:题解: 采用(1)中相加的方法: class Solution: def getConcatenation(self, nums: List[int]) -> List[int]: return nums+nums 采用(1)中切片赋值的方法: class Solution: def getConc 阅读全文
posted @ 2021-12-29 17:57 MoKin_Li 阅读(23) 评论(0) 推荐(0) 编辑
摘要:考察的重点,是列表拼接的方法: class Solution: def getConcatenation(self, nums: List[int]) -> List[int]: nums[len(nums):len(nums)]=nums return nums 列表拼接方法: 1、ListA+L 阅读全文
posted @ 2021-12-29 17:54 MoKin_Li 阅读(38) 评论(0) 推荐(0) 编辑
摘要:1、del语句:del语句->索引 2、方法:pop():pop()->索引 2.1、pop()进阶->pop()在括号中指定元素的索引,即可删除指定元素 # pop()方法删除的是列表的最后一个元素 >>> list1229_new [2, 3, 4, 2, 3, 2] # 首先是打印了一个列表 阅读全文
posted @ 2021-12-29 16:46 MoKin_Li 阅读(177) 评论(0) 推荐(0) 编辑