str 类型

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

 

转载于:https://www.cnblogs.com/lvjygogo/p/8439588.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值