1、首字母大写
语法:S.capitalize() -> str title = "today is a good day" title_ca = title.capitalize() print(title_ca) 结果:today is a good day
2、大写转小写
1 语法:S.casefold() -> str 2 3 title = "TODAY is a GOOD day" 4 title_ca = title.casefold() 5 print(title_ca) 结果:Today is a good day
3、字符串居中
c = ‘kong‘ ret = c.center(10,‘*‘) print(ret) 结果:***kong***
4、字符串子串数量统计
S.count(sub[, start[, end]]) -> int title = "today is a good day" title_ca = title.count(‘y‘,1,5) print(title_ca) 结果:1
时间: 2024-10-04 18:04:27