Created
February 11, 2018 07:20
-
-
Save Leask/8138985b364cf754e7ce2b5ba0604b6e to your computer and use it in GitHub Desktop.
Demo for reading text as array in Python3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array = []; | |
with open('test.txt', 'r') as f: | |
while True: | |
line = f.readline().strip() | |
if not line: | |
break | |
line = list(map(int, line.split(' '))) | |
array.append(line) | |
print(array) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 1 9 9 | |
6 3 2 8 | |
20 10 3 23 | |
1 4 1 10 | |
10 8 6 3 | |
10 2 1 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment