How can i make a 2D array with existing lists?

后端 未结 2 940
广开言路
广开言路 2021-01-28 11:47

for instance, i have a txt data called \'mazeline\' like this:

abcd
cdae
korp

So i first made 3 lists:

mazeline = readmaze.spli         


        
2条回答
  •  抹茶落季
    2021-01-28 12:45

    Try this list comprehension:

    [[int(i) for i in line.strip()] for line in open('file/path')]
    

提交回复
热议问题