看板 Python 關於我們 聯絡資訊
如圖 https://imgur.com/a/4I4ZQ 我想要讀的是第二列的資料 但資料讀成都會變成 4 1 9 7 這是第二列數字的意思 請問是否是不能打Line的語法呢? 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.25.192.242 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1521524054.A.56B.html
Panthalassa: 要先 split, 看起來是用 \t 分隔的? 03/20 13:44
Panthalassa: 可以 print(line.split(‘\t’)[1])。如果要去掉 03/20 13:44
Panthalassa: 換行符號,後面加 [0:-1] 或 .replace(‘\n’,’’) 03/20 13:44
謝謝P大,用1是指第一行對吧,Split是空白分割的意思
vfgce: python的list是從0開始... 03/20 13:57
TuCH: f.readlines()[1] 03/20 13:58
vfgce: 他要的是第二column,不是第二row. 03/20 14:00
對,不好意思沒講清楚,我是要4.32的那一欄~ ※ 編輯: phoebejen (114.25.192.242), 03/20/2018 14:02:46 ※ 編輯: phoebejen (114.25.192.242), 03/20/2018 14:18:02
Panthalassa: 從圖片中看 感覺分隔的不是空白 而是TAB (\t) 03/20 14:26