string_integers.txtRDD中的主要空白来自哪里以及如何避免它?
a 1 2 3
b 4 5 6
c 7 8 9
sample.py
import re
pattern = re.compile("(^[a-z]+)\s")
txt = sc.textFile("string_integers.txt")
string_integers_separated = txt.map(lambda x: pattern.split(x))
print string_integers_separated.collect()
结果
[[u'', u'a', u'1 2 3'], [u'', u'b', u'4 5 6'], [u'', u'c', u'7 8 9']]
预期结果
[[u'a', u'1 2 3'], [u'b', u'4 5 6'], [u'c', u'7 8 9']]
'类型错误:拆分()不带任何关键字参数' – 030