![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
集合
Code.ren
编程路上的小学生!正在努力学习
展开
-
字符串切片(Python)
[a:b] a是起点的索引位置,b是结束的索引位置。 代码如下: str2 = 'abc123456' print(str2[2:5]) 结果 c12 Python中支持下标索引从-1开始 代码如下: print(str2[-3:-1]) 结果 45 [a:b:c] c是步长 L=list(range(100)) L[0:10:2] # 0,2,4,6,8 取前十个数,每两个取一个 ...原创 2020-07-24 18:36:15 · 210 阅读 · 0 评论 -
字符串和常用数据结构 Python 100days
这里写目录标题使用字符串使用列表三级目录 使用字符串 def main(): str1 = 'hello, world!' 通过len函数计算字符串的长度 print(len(str1)) # 13 获得字符串首字母大写的拷贝 print(str1.capitalize()) # Hello, world! 获得字符串变大写后的拷贝 print(str1.upper()) # HELLO, WORLD! 从字符串中查找子串所在位置原创 2020-07-25 16:41:07 · 113 阅读 · 0 评论