03 2019 档案
摘要:创建列表 ❤ lst = [1, 2, 3, 'a', 'b', ('x', 'y', 'z')] print(lst) ❤ 从列表中获取元素 获取一个 ❤ lst = [1, 2, 3, 'a', 'b', ('x', 'y', 'z')] print(lst[3]) # a print(lst[
阅读全文
摘要:字符串 索引 & 切片 同样适用于:列表,元组等 切片: 截取完毕后不改变原数据类型 列表的索引: 索引出的部分 = 数据本身的类型 可能是整数,字符串,元组或其他 列表的切片: 截取出的部分 = 列表类型 ❤ lst = [1, 'a', ['one', 'two']] print(type(ls
阅读全文
摘要:去除字符串两边空格/字符 str.strip() s = ' -@love python@- ' print(s.strip()) #-@love python@- print(s.strip().strip('-')) #@love python@ print(s.strip('@')) # -@
阅读全文
浙公网安备 33010602011771号