各位前辈好,最近刚碰读取档案的问题,
老师出了一个简单的作业,
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()