Movatterモバイル変換


[0]ホーム

URL:


Easy question

Brian QuinlanBrianQ at ActiveState.com
Wed Apr 11 17:11:29 EDT 2001


How about something like this:# No testing, of coursemyList = []file = open( 'testfile', 'r' )for i in file.readlines( ):myList.append( [int(j.strip( )) for j in i.split('\t')] )-----Original Message-----From:python-list-admin at python.org[mailto:python-list-admin at python.org]On Behalf Of Duncan SmithSent: Wednesday, April 11, 2001 1:39 PMTo:python-list at python.orgSubject: Easy questionI need to read some data from a file.  Each (tab delimited) row correspondsto an array index eg.0    0    0    0    0    00    1    0    0    0    00    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.Duncan Smith--http://mail.python.org/mailman/listinfo/python-list


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp