# 1. 怎么将字符列表转为字符串l = ['python','circle','is','ok']s = ''.join(l)# 2. 怎么快速打印出包含所有 ASCII 字⺟(⼤写和⼩写)的字符串import stringstring.ascii_letters# 3. 怎么让字符串居中 # 注意*旁边的引号k = '更多精彩,尽在python知识圈'k.center(30)k.center(30,'*')# 4. 找到子串#使用find方法 返回的是index位置st = 'i love you'st.find('i')st.find('you')# 5. 首字母大写(所有单词的首字母)#第一种 .title()#第二种 使用string模块中的capwords 方法sl = 'hello world!'import stringstring.capwords(sl)# 6. 清空列表中的内容# 一 .clear()# 二 使用切片 赋值s = [1,2,3,4]s[:] = []s# 7. 在末尾添加其他元素# extend(需要添加的元素)# s70 + s71# 区别:extend 是在s70中直接添加元素,+ 会生成新的元素不对s70进行修改s70 = [1,2,3]s71 = [4,5,6]s70 + s71# 8. 查找元素第一次出现的下标(索引)_查找am# 貌似只能查找单词?# 使用字符串试一下——可以使用!s8 = ['hello','I','am','teacher']s8.index('am')s81 = 'Hello I\'m a teaher'asw = s81.index("e")asw# 9. 对象插入列表中# insert# 切片插入s9 = [1,2,3,4,5]s9.insert(2,'three')s9s90 = [1,2,3,4,5]s90[2:2] = ['three'] # 如果使用 'three' 则输出结果:[1, 2, 't', 'h', 'r', 'e', 'e', 3, 4, 5]s90