翁睿杕Python套件CSV比較EXCEL
import csv #輸入csv套件comma separated value
file = open('TWSE.CSV','r',encoding='utf-8') #打開下載的檔案TWSE.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)
for i in range(6):
print('輸出地',i,'公司:',rows[i-1])
print('台灣證券交易所公司家數',len(rows))
print('排在最後',[-1])
303.只有一个作业,一定要补做枢纽分析。https://d11417235.blogspot.com/2026/03/pythoncsvexcel.html
回复删除