![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
swe50
这个作者很懒,什么都没留下…
展开
-
Python列表常用方法
Python列表常用方法1. append()在列表的最后添加元素listA = ['鸡肉', '鸭肉']listA.append('鱼肉')print(listA) # ['鸡肉', '鸭肉', '鱼肉']2. insert(_index, _obj)在指定下标添加元素listA = ['A', 'C', 'D']listA.insert(1, 'B')print(listA) # ['A', 'B', 'C', 'D']3. extend()列表合并, 在列表末尾最佳另一个列原创 2021-12-20 10:55:56 · 387 阅读 · 0 评论 -
Python字符串常用方法
Python字符串常用方法1. len()获取字符串长度s = 'hello'print(len(s)) # 52. find()查找指定内容在字符串中是否存在, 如果存在就返回该内容在字符串中第一次出现的索引值s = 'hello'print(s.find('l')) # 23. startswith(), endwith()判断字符串是否以__为开头或者结尾返回true/falses = 'hello'print(s.startswith('c')) # trueprin原创 2021-12-16 17:05:46 · 742 阅读 · 0 评论