我有一個txt文件的數據,我只想從偶數行加載。np.loadtxt()如何從txt文件加載其他所有行? Python
有沒有辦法在Python中做到這一點,而不使用循環?
這裏是我的數據文件的第10行:
1 25544U 98067A 98324.28472222 -.00003657 11563-4 00000+0 0 10
2 25544 51.5908 168.3788 0125362 86.4185 359.7454 16.05064833 05
1 25544U 98067A 98324.33235038 .11839616 11568-4 57349-2 0 28
2 25544 51.6173 168.1099.0187 273.4932 16.04971811 11
1 25544U 98067A 98324.45674522 -.00043259 11566-4 -18040-4 0 32
2 25544 51.5914 167.4317 0125858 91.3429 269.4598 16.05134416 30
1 25544U 98067A 98324.51913017 .00713053 11562-4 34316-3 0 48
2 25544 51.5959 167.1152.8179 273.5890 16.05002967 44
1 25544U 98067A 98324.51913017 .00713053 11562-4 34316-3 0 59
2 25544 51.5959 167.1152.8179 273.5890 16.05002967 44
如何簡單,就是:'evens = a [0 :: 2]'和'odds = a [1 :: 2]',這是正確的方法,也應該更快。 – jadsq