擅长:python、mysql、java
<pre><code>arrays = []
with open('salida.txt', 'r') as wordfile:
for line in wordfile:
# Split the line on commas.
words = line.split(',')
for count, word in enumerate(words):
# Remove any whitespace.
word = word.strip()
# That might leave a blank string, e.g. at the end.
if word:
# Do we need to add another array to our list of arrays?
if count == len(arrays):
arrays.append([])
arrays[count].append(word)
print arrays
</code></pre>