本文共 365 字,大约阅读时间需要 1 分钟。
sc.parallelize(["one", "two", "two", "three", "three", "three"]).map(lambda x: (x,1)).repartition(1).saveAsTextFile("feature/all.txt")
load方法:
a=sc.textFile("feature/all.txt")
a.collect()[u"('one', 1)", u"('two', 1)", u"('two', 1)", u"('three', 1)", u"('three', 1)", u"('three', 1)"]
本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/bonelee/p/7767609.html,如需转载请自行联系原作者