2.安装Spark与Python练习
一、安装Spark
- 检查基础环境hadoop,jdk
- 配置文件
- 环境变量
- 试运行Python代码
二、Python编程练习:英文文本的词频统计
path='/home/xzm/f1.txt'
with open(path) as f:
text=f.read()
words=text.upper()
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)
for i in range(5):
word,wc=wclist[i]
print("#{0:<10}{1:>5}".format(word,wc))
三、