I have data in text file :
2,58 1,23 0,14
6,58 4,2 1,3
I want to have this data from my text file in list written in this format:
[[2, 58, 1, 23, 0, 14]
[6, 58, 4, 2, 1, 3]]
I tried this :
folder = open('text.txt', encoding = 'utf-8')
data = [numbers.strip().replace(',',' ').split(' ') for numbers in folder]
folder.close
print(data)
But I received result like this : [['2', '58', '1', '23', '0', '14']['6', '58', '4', '2', '1', '3']]
If I'm trying to set int()
to numbers in many places in list I receiving this error : int() argument must be a string, a bytes-like object or a number, not list
So I need just change all string in this list from str
to int
, can you help me, please?