1.capitalize():首字母大写

2.center(size,fillwith):

3.count(sub,start,end):计算子序列的个数

4.decode()

5.encode()

6.endswith(sub,start,end)

7.expandtabs([num]):将tab替换成空格 \t

8.find(sub):查找子序列的位置,返回第一个找到的子序列的位置

9.format()

1 s="hello {0},my name is {1}"
2 print(s.format("lvjy","30"))

10. index()

11.isalnum():是否是字母和数字

12.isalpha():是否是字母

13.isdigit():是否是数字

14.islower():是否都是小写字母

15.isspace():判断是否是空格

16.istitle():是否是标题,即所有单词首字母大写

17.isupper():

18.join():

1 elem=["lv","junyi","bjtu"]
2 line="-"
3 print(line.join(elem))
View Code

19.ljust(with,fillwith):内容左对齐,右侧填充

20.lstrip():移除左空格

21.rstrip():移除右空格

22.strip():移除两边空格

23.partition(sep):分隔字符串

str1="hello ni hao"
print(str1.partition("ni"))
View Code

 24.replace(ori,new,count):替换

25.split():分隔

26.swapcase():大小写翻转

27.title():

1 str1="hello ni hao"
2 print(str1.title())
View Code

28.zfill(width):右对齐,前边填充零

29.切片和索引

1 name="lvjunyi"
2 print(name[2])
3 print(len(name))
4 print(name[0:2])
View Code

30.for循环

1 for item in name:
2     print(item)
View Code

 

posted on 2018-02-10 19:38  sonofthesea  阅读(189)  评论(0编辑  收藏  举报