2016-11-07 56 views

回答

1

可以使用arrow.Arrow类的strptime类方法并应用适当的formattting:

y = datetime.time() 
print(arrow.Arrow.strptime(y.isoformat(), '%H:%M:%S')) 
# 1900-01-01T00:00:00+00:00 

但是,你会发现日期值是默认的,所以你可能会更好过解析一个datetime对象而不是一个time对象。

2

箭遵循特定的格式,其文件中规定:

arrow.get('2013-05-11T21:23:58.970460+00:00') 

您需要将您的DateTime对象转换为箭头可以理解的格式,以便能够将其转换为一个箭头对象。下面的代码块应该工作:

from datetime import datetime 
import arrow 

arrow.get(datetime.now())