"与格式不匹配"​​错误从字符串解析日期时间

bsr*_*bsr 0 python

试图从字符串中解析时间,但得到此错误.试过几个格式化字符串.

错误:

time data '10/2/2010 0:00:00' does not match format '"%m/%d/%Y %H:%M:%S"'
Run Code Online (Sandbox Code Playgroud)

码:

strdt = '10/2/2010 0:00:00'
dt = datetime.strptime(strdt, '"%m/%d/%Y %H:%M:%S"')
Run Code Online (Sandbox Code Playgroud)

Mar*_*som 8

您的格式中包含引号.拿出来.

dt = datetime.strptime(strdt, '%m/%d/%Y %H:%M:%S')
Run Code Online (Sandbox Code Playgroud)