#字典#把字符串中的字母提取出来改为大写并计数 a="aAsmr3idd4bgs7Dlsf9eAF" b1=[x for x in a if x.isalpha()] b=''.join(b1) b=b.upper() s=dict([(x,b.count(x)) for x in b]) print(s) #先格式化输出,再整理成字典,key是字母,value是出现的次数 a="aAsmr3idd4bgs7Dlsf9eAF" #转为纯字母的字符串 b1= [i f…
python字符串replace()方法 >>> help(str.replace)Help on method_descriptor:replace(...) S.replace(old, new[, count]) -> string Return a copy of string S with all occurrences of substring old replaced by new. If the optional argument cou…