![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
她有少女心
学无止境啊
展开
-
python中常用的字符串操作
1、切片与步长2、find、index、startswith、endswith、rfind、rindex3、count4、replace5、split、splitlines、partition、rpartition6、join7、capitalize、title、lower、upper8、ljust、rjust、center9、lstrip、rstrip、strip10、isalpha、isdig原创 2018-02-01 11:34:17 · 212 阅读 · 0 评论 -
python中字典的常见操作
1、获取value值,不存在则报错:dictname[key]2、添加或修改键值对,存在则修改不存在则新增:dictname[key]=value3、清空字典:dictname.clear()4、删除键值对或删除字典:del dictname[key]/del dict5、字典中键值对的个数:len(dictname)6、字典所有key,返回的是列表:dictname.keys原创 2018-02-01 12:21:16 · 252 阅读 · 0 评论 -
python中最常见数据结构的遍历:字符串、列表、元祖、字典
1、字符串遍历strs="hello world!"for str in strs: print(str,end=" ")2、列表遍历list = [1, 2, 3, 4]for num in list: print(num,end=' ')3、元组遍历turple = (1, 2, 3, 4)for num in turple: print(num,end原创 2018-02-01 12:40:07 · 2458 阅读 · 0 评论