小编Gal*_*ado的帖子

模块“datetime”没有属性“strptime”

我对编程完全陌生,我正在尝试使用 Python 来使用 Pythin 读取 CSV 文件。我正在使用 Spyder 执行此操作。我收到错误“模块‘datetime’没有属性‘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=[]      
Run Code Online (Sandbox Code Playgroud)

对于读卡器中的行:

date=datetime.strptime(row[0], '%m/%d/%y')
Run Code Online (Sandbox Code Playgroud)

这是我收到的错误消息。

date=datetime.strptime(row[0], '%m/%d/%y')

AttributeError: module 'datetime' has no attribute 'strptime'
Run Code Online (Sandbox Code Playgroud)

datetime strptime attributeerror

13
推荐指数
1
解决办法
9331
查看次数

标签 统计

attributeerror ×1

datetime ×1

strptime ×1