2.安装Spark与Python练习

一、安装Spark

1.检查基础环境hadoop,jdk

 

 

 

 

 

 二、Python编程练习:英文文本的词频统计

f1文本文件

There are moments in life when you miss someone so much that you just want to pick them from your dreams and hug them for real! Dream what you want to dream;
go where you want to go;be what you want to be,because you have only one life and one chance to do all the things you want to do.

插入代码

path='/home/hadoop/wc/f1.txt'
with open(path) as f:
    text=f.read()
words = text.split()
wc={}
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)

输出结果

 

 

posted @ 2022-03-04 19:26  贴贴贴贴  阅读(33)  评论(0编辑  收藏  举报