我是一个全新的编程新手,我正在尝试python使用Pythin读取CSV文件。我正在使用Spyder来做这件事。我得到了一个错误"module 'datetime‘has no attribute 'strptime'",并且不能解决这个问题。我们将感谢您的帮助。下面是我的代码:
import os
import csv
from datetime import datetime
path=csvpath=os.path.join("..","Practice","Google Stock Market Data -
google_stock_data.csv")
file=open(path,newline="")
reader=csv.reader(file)
header=next(reader)
data=[] 对于读取器中的行:
date=datetime.strptime(row[0], '%m/%d/%y')下面是我得到的错误消息。
date=datetime.strptime(row[0], '%m/%d/%y')
AttributeError: module 'datetime' has no attribute 'strptime'发布于 2021-02-27 11:31:06
尝试使用datetime.datetime.strptime()
日期=datetime.datetime.strptime(行,'%m/%d/%y')
https://stackoverflow.com/questions/54842868
复制相似问题