2024-09-27 07:35:36 发布
网友
如何在Python中为当前日期添加1秒。我能够分别获取当前日期和秒数,但我不确定如何在其中添加1秒
currentDate = MXServer.getMXServer().getDate() currentSecond = currentDate.getSeconds() newSecond = currentSecond - 1
你必须使用日历。例如
from java.util import GregorianCalendar from psdi.server import MXServer currentDate = MXServer.getMXServer().getDate() cal = GregorianCalendar() cal.setTime(currentDate) cal.add(cal.SECOND, 1) print "currentDate: %s\nplusSecond: %s" % (currentDate.toString(), cal.getTime().toString())
你必须使用日历。例如
相关问题 更多 >
编程相关推荐