标签:bcd api 序列 lower UI 补充 center pre 字母转
name = "zhengkUI" new_name = name.capitalize() # 1.首字母大写,其它字母小写 print(new_name)
str1 = "abcd" str1_new = str1.upper() # 2.将字符串中的字母转成大写 print(str1_new)
str2 = "AbCDE" str2_new = str2.lower() # 3.将字符串中的字母转成小写 print(str2_new)
name = "zhengkui" new_name = name.center(20,"-") # 4.字符串居中(共多少个字符,空位用什么补充-补充的字符必须是单字符) print(new_name)
str1 = "zhengkui lisi abao keke" num = str1.count("en") # 5.子序列的个数-可以是单个字符的字符串也可以是多个字符的字符串 print(num)
标签:bcd api 序列 lower UI 补充 center pre 字母转
原文地址:https://www.cnblogs.com/zhengkui/p/9052915.html