2021年3月11日星期四

Stop condition For in python

I have a text file containing lines like the following:

3.8,5.4,1.4,12.6,3.5,1.8,7.9,yes  3.4,5.4,1.4,12.6,2.5,7.0,5.9,yes  3.8,5.4,1.7,12.6,5.5,8.8,4.9,yes  3.9,5.4,1.1,12.6,2.5,1.2,1.9,no  

I'm trying to make that file into a list with the following code:

datos=[]  with open('archivo.data') as f:      for linea in f:          datos.append([int(n) for n in linea.split(",") ])  

How can I convert to int only until the penultimate column?

https://stackoverflow.com/questions/66594454/stop-condition-for-in-python March 12, 2021 at 01:03PM

没有评论:

发表评论