I am encounter a problem when reading a list saved in txt:
I have python program which generates random number sets and saved them into the txt: for example the data in txt is as follow:
I have tried the following 2 codes to read the above txt:
data = open(r"201219.txt", 'r') lines = data.readlines() for line in lines: for i in line: print(i)
with open(r"201219.txt", 'r') as data: lines = data.read().splitlines() for line in lines: for i in line: print(i)
Both of the above codes will print something like:
Instead of what i want below:
It seems the code is reading each character instead of a number itselt.
Does anyone know how to deal with this? Thanks very very much.