作为我新工作的一部分,我需要将一个现有的java类转换为python类。
person.setDob(String.valueOf(person.getDateOfBirth().getTime()));
请看上面的代码片段,看看如何在python中从date对象中获取以毫秒为单位的时间,希望我可以使用datetime.datetime来实现这个目的。请帮帮忙。
发布于 2019-03-11 20:06:22
要在python中获取毫秒数,请使用以下代码。
import datetime
print('Datetime in milliscond using now()',datetime.datetime.now())
print('Datetime in milliscond using utcfromtimestamp()', datetime.datetime.utcfromtimestamp(0))
输出如下所示
Datetime in milliscond using now() 2019-03-11 17:34:28.290409
Datetime in milliscond using now() 1970-01-01 00:00:00
https://stackoverflow.com/questions/55101306
复制相似问题