Python值错误:未转换的数据保留:09

2024-06-25 23:06:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在处理两个包含日期列的csv文件,第一个csv文件可以很好地处理我的代码,但是第二个文件显示为“ValueError:unconverteddata remains:09”。在

下面是我的代码和截图,有人能帮我吗??在

代码:

with open(source_csv,newline="") as csvfile:

  csvreader = csv.reader(csvfile, delimiter=',', quotechar='|')

  next(csvreader, None)  # skip the headers

  for row in csvreader:

    dictList.append([datetime.strptime(row[0],'%b-%d').strftime('%m%d%Y'),row[1], row[0]])
    mmyy = row[0].split("-")
    month.append(str(mmyy[0]))
    total += int(row[1])

错误: enter image description here

csv文件: enter image description here


Tags: 文件csvcsvfile代码sourcewithnewlineopen