标签:asd index 统计 tar pre map form mat 出现
#capitalize()首字母大写 t = "james" v = t.capitalize() print(v) #lower()所有“英文”字母小写 t1 = "AbCdeFg" v1 = t1.lower() print(v1) #casefold()所有“语言”字母小写 t2 = "AbCdeFg" v2 = t2.lower() print(v2) #center(width,str):用str填充,居中,总的占width个位置,str默认为空格 #个人觉得用来做输出菱形的题非常适合 t3 = "alen" v3 = t3.center(20,‘*‘) v3_1 = t3.center(20) print(v3) print(v3_1) #count(str,i,j):从第i个位置开始,j结束,统计str出现的次数。i,j可省略 t4 = "asdfgfd" v4 = t4.count(‘f‘) print(v4) #endwith(str):是否以str结尾 t5 = "James" v5 = t5.endswith("es") print(v5) #find(str,star,end):返回str第一次出现的位置 t6 = "abcdefg" v6 = t6.find("bcd") print(v6) #format():格式化字符串!!!!!! t7 = "I am {name},and my age is {age}." v7 = t7.format(name=‘James‘,age=35) print(v7) #format_map(): t8 = "I am {name},and my age is {age}." v8 = t8.format_map({"name":"James","age":35}) print(v8) #index(str):和find()一样,只不过index()找不到就报错了,而find()是返回-1 #isalnum():判断是否只有字母和数字组成
标签:asd index 统计 tar pre map form mat 出现
原文地址:https://www.cnblogs.com/SlowIsFast/p/12914098.html