Ubuntu14.04 给定一个文本,统计其中单词出现的次数 方法1 # solution 1 grep与awk配合使用,写成一个sh脚本 fre.sh sh fre.sh wordfretest.txt #! /bin/bash# solution 1 ] then echo "Usage:$0 args error" exit fi ] then echo "analyse the first file $1" fi #get the first file fi…
name = input("Enter file:") if len(name) < 1 : name = "input.txt" fhand = open(name) counts = dict() for line in fhand: words = line.split() for word in words: # find the value that key is word, if not, return 0 counts[word] = count…