细节1: 参数newline=''可以去掉空行
细节2:csv_writer.writerow(V),一次写一行数据,V是一个list
V = []
V.append(filename)
localtime = time.localtime(time.time()) #获取当前时间
t = time.strftime('%Y%m%d',time.localtime(time.time())) #把获取的时间转换成"年月日格式”
csv_path_enr = 'getinfo-' + str(t) + '.csv'
with open(csv_path_auth, 'a+',newline='') as csvopen:
csv_writer = csv.writer(csvopen)
csv_writer.writerow(["file_name","type","value"]) #表头
csv_writer.writerow(V)