陳瑀晞期中考python讀取csv檔案
到「程式交易040」下載檔案,然後拷貝程式碼,貼到spyder,另存新檔案abc.py但一定要和下載的檔案同一目錄。
電腦學過HTML, CSS(控制網頁的樣式style), Javascript, Python
import csv#陳瑀晞python #輸入csv套件comma separated value file = open('SPY.CSV','r') #打開下載的檔案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('陳瑀晞分析資料數目'+str(len(rows)))
參考的線內css指令
<pre style='border: 3px double blue'>double也可以使用其他實心solid點線dotted虛線dashed
https://chen-yu-hsi.blogspot.com/2025/06/pythoncsvtkintermarkowitz.html
回覆刪除https://chen-yu-hsi.blogspot.com/2025/05/csv.html
https://chen-yu-hsi.blogspot.com/2025/06/blog-post.html
https://chen-yu-hsi.blogspot.com/2025/04/500spy.html
https://chen-yu-hsi.blogspot.com/2025/06/listdictrandom.html
https://chen-yu-hsi.blogspot.com/2025/04/pythoncsv.html
蒙地卡羅。https://chen-yu-hsi.blogspot.com/2025/03/202537d11117311.html
321開始繳交作業。https://chen-yu-hsi.blogspot.com/2025/06/pythoncsvtkintermarkowitz.html