#白皓宇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,直接讀成字典
Jupyter執行python
影片
python.org說明csv與DictReader
class csv.DictReader(f, fieldnames=None, restkey=None, restval=None, dialect='excel', *args, **kwds)
建立一個物件,其運作上就像一般的讀取器,但可以將每一列資訊 map (對映) 到 dict 中,可以透過選填的參數 fieldnames 設定 key。
參數 fieldnames 是一個 sequence。如果 fieldnames 被省略了,檔案 f 中第一列的值會被當作欄位標題,且於結果中會被省略。如果 fieldname 有提供,它們就會被使用,且第一列會被包含在結果中。不管欄位標題是如何決定的,dictionary 都會保留原始的排序。
如果一列資料中的欄位比欄位標題還多,其餘的資料及以 restkey (預設為 None)特指的欄位標題會放入列表當中並儲存。如果一個非空的 (non-blank) 列中的欄位比欄位標題還少,缺少的值則會填入 restval (預設為 None)的值。
所有其他選填的引數或關鍵字引數皆會傳遞至下層的 reader 實例。
如果傳遞至 fieldnames 的引數是個疊代器,則會被迫成為一個 list。
https://erichtml-css-javascript-java.blogspot.com/2025/03/python.html
回覆刪除https://python-spencer.blogspot.com/2025/03/pythoncsvspdr500etf19931292025320.html
回覆刪除https://d1111735.blogspot.com/2025/03/pythoncsvspdr500etf19931292025320.html
回覆刪除https://gary20010101.blogspot.com/2025/03/pythoncsvspdr500etf19931292025320.html
回覆刪除https://d11117102.blogspot.com/2025/03/pythoncsvspdr500etf19931292025320.html
回覆刪除https://kuanhtml-css-javascript-java.blogspot.com/2025/03/pythoncsvspdr500etf19931292025320.html
回覆刪除https://hsuppppp.blogspot.com/2025/03/pythoncsvspdr500etf19931292025320.html
回覆刪除https://cynthiachen59.blogspot.com/2025/03/pythoncsvspdr500etf19931292025320.html
回覆刪除https://python-wopoyan.blogspot.com/2025/03/pythoncsvspdr500etf19931292025320.html
回覆刪除https://d11117220takminggh.blogspot.com/2025/03/pythoncsvspdr500etf19931292025320.html
回覆刪除https://d11117129.blogspot.com/2025/03/pythonspy.html
回覆刪除https://leo1050317.blogspot.com/2025/03/pythoncsvspdr500etf19931292525320.html
回覆刪除https://o3og413.blogspot.com/2025/03/pythoncsvspdr500etf19931292025320.html
回覆刪除https://chenjiayu.blogspot.com/2025/03/pythoncsvspdr500etf19931292025320.html
回覆刪除https://d11117328.blogspot.com/2025/03/pythoncsvspdr500etf19931292025320.html
回覆刪除https://takmingd11117330.blogspot.com/2025/03/pythoncsvspdr500etf1993129202532.html
回覆刪除https://takmingd11117329.blogspot.com/2025/03/pythoncsvspdr500etf.html
回覆刪除https://yangyoyo0125.blogspot.com/2025/03/pythoncsvspdr500etf19931292025320.html
回覆刪除https://chen-yu-hsi.blogspot.com/2025/03/pythoncsvspdr500etf19931292025320.html
回覆刪除https://linpeiyud11117127.blogspot.com/2025/03/pythoncsvspdr500etf19931292025320.html
回覆刪除https://d11117312d.blogspot.com/2025/03/pythoncsvspdr500etf19931292025320.html
回覆刪除https://rivkydf.blogspot.com/2025/03/pythonspy.html
回覆刪除https://d11112215.blogspot.com/2025/03/pythoncsvspdr500etf19931292025320.html
回覆刪除https://jennysuwanting.blogspot.com/2025/03/pythoncsvspdr500etf19931292025320.html
回覆刪除https://zoetakming.blogspot.com/2025/03/pythoncsvspdr500etf19931292025320.html
回覆刪除https://draft.blogger.com/blog/post/edit/4298750042803102942/3450042950077348819
回覆刪除https://mandytakming.blogspot.com/2025/03/pythoncsvspdr500etf19931292025320.html
回覆刪除https://meishiuanlin.blogspot.com/2025/03/pythoncsvspdr500etf19931292025320.html
回覆刪除https://d10917245test.blogspot.com/2025/04/pythoncsvspdr500etf19931292025320.html
回覆刪除