當前位置:成語大全網 - 新華字典 - python中統計壹個字母出現的次數

python中統計壹個字母出現的次數

a = input("請輸入字符串:")

b = list(a.lower()) #將輸入的字符全部轉換為小寫字母

c = {} #建立壹個空字典

for i in b: #for循環遍歷出結果

c[i] = b.count(i)

print(c)

輸出結果: