day4字符串、列表

字符串:

strip,lstrip,rstrip
去首尾 lower,upper
小写 、大写 startswith,endswith
判断字符头、尾跟输出字符是否一样(true false) format的三种玩法
格式化输出占位

res='{},{}'.format('aa',18)# 按顺序占位


res='{1},{0}'.format('aa',18)#按索引占位


res='{age},{name}'.format(name='aa',age=18)#按映Key占位


split,rsplit
切割 join
拼接 传入列表只包括字符串 replace
替换 isdigit
判断是否为数值

find 找到索引位置,找不到返回-1
a.center(n,'*') n=1、2…… 共有N个字任不够、用*补齐
expandtabs 用table 键功能补齐
a='lige'
print(a.capitalize())---->首写母大写
print(a.swapcase())---->全部大写

title() 每个单词首字母大写

追加
a.append() 从尾部开始一次一个
a.insert(n,'字符串')按索引插入值

删除
remove(‘字符’) 纯删除
pop(n)弹出可以赋值

count(元素个数)
extend(扩展多个值)
index(n)取索引
reverse倒序反转
sort 排序




原文地址:https://www.cnblogs.com/lg04551/p/8609181.html