林姵語python讀取CSV檔案SPDR標普500ETF在1993/1/29至2025/3/20

#林姵語python程式碼分析spy:標準500ETF
import csv #輸入套件csv=comma seperated value                     #輸入csv套件comma separated value
file = open('SPY.CSV','r')     #打開下載的檔案SPY.CSV,模式是r讀取,
csvreader = csv.DictReader(file) #將檔案讀入變數csvreader
for row in csvreader:       #檔案接續逐列附加append於rows串列
#    print(row)
    print(row['日']+' 當天收盤價 '+row['收'])
file.close()            #關閉檔案
#上一個作業讀近來放成串列list,直接讀成字典

留言

  1. 確實執行python.https://linpeiyud11117127.blogspot.com/2025/06/pythoncsvtkintermarkowitz.html
    https://linpeiyud11117127.blogspot.com/2025/06/listdictrandom.html
    沒有影片!https://linpeiyud11117127.blogspot.com/2025/05/2025power.html
    https://linpeiyud11117127.blogspot.com/2025/05/powerpoint1mp41mp4.html
    https://linpeiyud11117127.blogspot.com/2025/05/csv.html
    https://linpeiyud11117127.blogspot.com/2025/04/pythoncsv.html
    https://linpeiyud11117127.blogspot.com/2025/04/500spy.html
    https://linpeiyud11117127.blogspot.com/2025/03/pythoncsvspdr500etf19931292025320.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

林姵語python運算CSV輸出TKINTER投資風險與報酬Markowitz