启动hdfs查看进程
配置Spark的classPath,并加上最后一行代码
path='/home/hadoop/wc/f1.txt' with open(path) as f: text=f.read()
步骤三+步骤四
words = text.split()
for word in words: wc[word]=wc.get(word,0)+1
wclist=list(wc.items()) wclist.sort(key=lambda x:x[1],reverse=True)
print(wclist)
运行结果截图