python的内置方式

count()
center()
startswith()
find()
format()
lower()
upper()
strip()
replace()
split()
str = ‘hellow python’
str.count(‘l’)#计算单个字符再字符串中的个数,统计元素个数
1
2
2
1
str.capitalize()#字符串的首字母大写
1
‘Hellow python’
1
str.center(50,’’)#居中
1
'hellow python

1
str.endswith(‘y’)# 看以某个内容结尾
1
False
1
str.startswith(‘he’)
1
True
1
str2 = ‘he\tllow python’
print(str.expandtabs(tabsize=20))
1
2
hellow python
1
str.find(‘p’)#找寻元素返回索引值
1
7
1
str2 = ‘hellow python {boy}’
str2.format(boy = ‘bob’)
1
2
‘hellow python bob’
1
str.index(‘p’)
1
7
1
str3 = ‘123asf’
str3.isalnum()#判断是否有字母字符串
1
2
True
1
str3.isdecimal()#判断是否是十进制的数
1
False
1
str3.isdigit()#判断是否是数字
1
False
1
str3.isnumeric()
1
False
1
str3.isidentifier()#检验是否是非法变量
1
False
1
str3.islower()#判断是否都是小写
1
True
1
str3.isupper()#判断是否都是大写
1
False
1
str.isspace()#判断是否是空格
1
False
1
‘My Python’.istitle()#判断是否是标题的格式
1
True
1

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值