廖秀穎python讀取CSV


  import csv #輸入csv套件comma separated value

file = open('SPY.CSV','r',encoding='utf-8')     #打開下載的檔案SPY.CSV,模式是r讀取,
csvreader = csv.reader(file)   #將檔案讀入變數csvreader
header, rows = [], []           #宣告空白串列(陣列,清單)
header = next(csvreader)       #串列header儲存檔案第一列
for row in csvreader:          #檔案接續逐列附加append於rows串列
   rows.append(row)
file.close()                        #關閉檔案
print(header)
print('廖秀穎分析列數:',len(rows))#視窗放大按下CTRL +

留言

  1. 期中考有影片!https://11217133d.blogspot.com/2026/04/h1background-colorpinkcolorwhitetext.html
    https://11217133d.blogspot.com/2026/04/4-16-2026.html
    https://11217133d.blogspot.com/2026/04/pythoncsv.html

    回覆刪除
  2. 期中考有影片!https://11217133d.blogspot.com/2026/04/h1background-colorpinkcolorwhitetext.html
    https://11217133d.blogspot.com/2026/04/4-16-2026.html
    https://11217133d.blogspot.com/2026/04/pythoncsv.html
    https://11217133d.blogspot.com/2026/03/excelpythoncsvmatplotlib-3-12-2026.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

廖秀穎 金三甲期末考重要題庫與額未加分作業

廖秀穎地卡羅模擬,遊戲驛站軋空事件0424