“”“這是一段讀取文件,統計文件中相同字母出現的頻率的代碼,然後在屏幕輸出,雖然能統計相同字符的出現頻率,但大寫和小寫系統還是認為是2個字母,誰能指點一下,還有最好用lambda函數來表達同一個字符出現的頻率”“”from os import strerrorcounters = {chr(ch): 0 for ch in range(ord('a'), ord('z') + 1)}print(counters)file_name = input("Enter the name of the file to analyze: ")try: f = open("textfile.txt", "rt") for line in f: for char in line: if char.isalpha(): char.lower() x=set(line) f.close() for item in x: counters[item]=line.count(item.lower()) cnt=counters[item] if cnt > 0: print(item, '->',cnt)except IOError as e: print("I/O error occurred: ", strerror(e.errno))"""output:輸入cbaBaa輸出a -> 3c -> 1b -> 2