Movatterモバイル変換
[0]ホーム
Easy question
Terry Reedytjreedy at udel.edu
Wed Apr 11 17:09:57 EDT 2001
> I need to read some data from a file. Each (tab delimited) rowcorresponds> to an array index eg.> 0 0 0 0 0 0> 0 1 0 0 0 0> 0 0 1 0 0 0> And I need something like,> [[0,0,0,0,0,0], [0,1,0,0,0,0], [0,0,1,0,0,0], ...]> What's the best way of doing this? Cheers in advance.Easy (pseudocode) answer:result = []for each line (read 1 at a time or all at once), split on \t and append toresultIf need to (not clear) convert '0','1' strings to 0, 1 numbers.TJR
More information about the Python-listmailing list
[8]ページ先頭