0
我需要編寫一個函數來計算文件中的所有單詞並打印單詞的平均長度。 (標點符號務必被刪除。)如何計算平均值?
def average(fileName):
infile = open(fileName,'r')
wordcount = {}
for word in infile.read().split():
if word not in wordcount:
wordcount[word] = 1
else:
wordcount[word] += 1
我很努力得到一個字數與刪除標點符號.... – ZigZag