import csv
with open('108年產業及社福外籍勞工人數_縣市.csv',newline = '') as csvfile:
csvreader = csv.DictReader(csvfile)
for old in csvreader:
print(old['產業及社福外籍勞工人數'])
其顯示錯誤:
Traceback (most recent call last):
File "c:\Users\Eric Chang\Eric\python\108labor.py", line 5, in
print(old['產業及社福外籍勞工人數'])
KeyError: '產業及社福外籍勞工人數'
import pandas as pd
df = pd.read_csv('108年產業及社福外籍勞工人數_縣市.csv')
print(df)