logo
Loading...

day2 / where the difference between file I/O and CSV reader - Cupoy

1. there is no difference if i use readlines() ins...

pycrawler,pycrawler-d02

day2 / where the difference between file I/O and CSV reader

2019/12/11 上午 00:18
Python網路爬蟲討論版
Tommie Chen
觀看數:3
回答數:2
收藏數:0
pycrawler
pycrawler-d02

1. there is no difference if i use readlines() instead of read()   

    why ??


thx

回答列表

  • 2019/12/11 下午 02:50
    寶寶
    贊同數:2
    不贊同數:0
    留言數:2

    不一樣啊..你可以自己測試每種type

       # File I/O

           # f.readlines() 讀取結果一個row是str,全部組合起來才是list

       # CSV Reader

           # csv.reader(f) 資料型態為物件(_csv.reader object)

           # 取出物件每個元素就是每個row,每個row為 每個column是str   組成之list

  • 2019/12/12 上午 11:37
    張維元 (WeiYuan)
    贊同數:2
    不贊同數:0
    留言數:1

    Yap,如同寶寶說的,其實你直接跑跑看就知道差異了。簡單來說 file I/O 讀入的字串,and CSV reader 讀入的依照 CSV 解析成的 List。