摘要: 创建列表 ❤ 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[ 阅读全文
posted @ 2019-03-20 17:51 noraccc 阅读(87) 评论(0) 推荐(0)
摘要: 字符串 索引 & 切片 同样适用于:列表,元组等 切片: 截取完毕后不改变原数据类型 列表的索引: 索引出的部分 = 数据本身的类型 可能是整数,字符串,元组或其他 列表的切片: 截取出的部分 = 列表类型 ❤ lst = [1, 'a', ['one', 'two']] print(type(ls 阅读全文
posted @ 2019-03-19 00:26 noraccc 阅读(98) 评论(0) 推荐(0)
摘要: 去除字符串两边空格/字符 str.strip() s = ' -@love python@- ' print(s.strip()) #-@love python@- print(s.strip().strip('-')) #@love python@ print(s.strip('@')) # -@ 阅读全文
posted @ 2019-03-17 02:26 noraccc 阅读(178) 评论(0) 推荐(0)