各位前輩好,最近剛碰讀取檔案的問題,
老師出了一個簡單的作業,
https://imgur.com/a/xMCzj0e
讀取csv檔將每一筆資料列印出來,但須對齊排列,爬了很多文,但我輸出的結果都是如此
https://imgur.com/a/QCuVBQh
並且最後會多很多的逗號,想問各位前輩應該怎麼修改程式碼
import os
import csv
from io import TextIOWrapper
from io import BytesIO
import requests
import urllib
from urllib.request import urlretrieve # used to copy a network object to a loc
al file
url = 'https://datacenter.taichung.gov.tw/swagger/OpenData/6bb100e6-0f81-4e3a-8d
23-7fe16f929bf1'
urlretrieve(url, 'hw1_data.csv')
hw1_data.csv =
open('hw1_data.csv', 'r', encoding = 'utf-8-sig', newline = '') as csvfile:
plots = csv.reader(csvfile, delimiter = ':')
for row in plots:
print('%20s'%row[0])
csvfile.close()