如何从一个.net日期时间转换为IronPython的日期时间? [英] How do I convert from a .NET DateTime to an IronPython datetime?
本文介绍了如何从一个.net日期时间转换为IronPython的日期时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我打电话的IronPython的脚本,并传递给它一个包含的DateTime
结构的.NET对象。
I'm calling an IronPython script and passing it a .NET object that contains a DateTime
structure.
我试图使用IronPython的的JSON支持对象为JSON序列化。
I'm trying to use IronPython's JSON support to serialize the object as JSON.
一切都很正常,直到我遇到了.NET 的DateTime
。
Everything works great until I encounter the .NET DateTime
.
我如何从.NET 的DateTime
的IronPython的转换日期时间
?
How do I convert from the .NET DateTime
to the IronPython datetime
?
推荐答案
预见,人们可能会喜欢这些之间的转换,我们实际上使其很容易:
Anticipating that people might like to convert between these we actually make it really easy:
import datetime
from System import DateTime
datetime.datetime(DateTime.Now)
这篇关于如何从一个.net日期时间转换为IronPython的日期时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文