我有以空格隔开的字符串格式的日期,并且我试图使用datatime将其转换为日期,以便稍后我可以根据名称列和日期列对数据进行排序。这是我的代码:
from datetime import datetime
DATE = '1 nov 2010'
current_date = datetime.strptime(DATE, '%d %b %y')
print(current_date)
这是我得到的错误:
Traceback (most recent call last):
File "DEL.py", line 4, in <module>: current_date = datetime.strptime(DATE, '%d %b %y')
File "lib\_strptime.py", line 565, in _strptime_datetime: tt, fraction = _strptime(data_string, format)
File "lib\_strptime.py", line 365, in _strptime:
data_string[found.end():])
ValueError: unconverted data remains: 10
我已经检查了有关该主题的所有先前问题,并且由于我没有任何隐藏字符或任何东西,因此似乎都不适用于这种情况,就像键入日期一样简单。感谢有人可以帮我解决这个问题。
答案 0 :(得分:1)
var Fo =new ActiveXObject("Scripting.FileSystemObject");
var StrOut = new String();
var FileName = new String();
var Extention = new String();
function FindFile(FOo)
{
var FSo = new Enumerator(FOo.Files);
for(i=0;!FSo.atEnd();FSo.moveNext())
{
if(FileName == "*" || FSo.item().name.slice(0,FSo.item().name.lastIndexOf(".")).toLowerCase().indexOf(FileName)>-1)
if(Extention == "*" || FSo.item().name.slice(FSo.item().name.lastIndexOf(".")+1).toLowerCase().indexOf(Extention)>-1){
StrOut += "<tr "+ ((i%2)? "":"bgcolor=#DDAA55") +"><td width=50%><font class=find>" + FSo.item().path + "</font></td><td width=25%><font class=find>" + FSo.item().type + "</font></td><td width=50%><font class=find>"+ String(FSo.item().size/(1024*1024)).slice(0,3) +" MB</font></td></tr>";
i++
}
}
}
function Scan()
{
FileName = (search.value.lastIndexOf(".")>-1)? search.value.slice(0,search.value.lastIndexOf(".")):(search.value.length>0)? search.value.toLowerCase():"*"; //Get Searched File Name
Extention = (search.value.lastIndexOf(".")>-1)? search.value.slice(search.value.lastIndexOf(".")+1).toLowerCase():"*"; // Get Searched File Extention Name
if(path.value.length>0 && Fo.FolderExists(path.value)){
StrOut = "<table border=0 width=100% cellspacing=0>"
FindFile(Fo.GetFolder(path.value));
outPut.innerHTML = StrOut+"</table>";
}
else alert("Insert Correct Path Address");
}
的{{1}}参数是"Year without century"。您需要大写的%y
。