作业二,安装spark跟python
一、安装Spark
1.检查基本环境Hadoop、jdk

2.配置文件,环境变量


3.试运行python代码


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

2.读文件,预处理,分词,统计每个单词出现的次数,按词频大小排序
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)
3.结果写文件


浙公网安备 33010602011771号