Can't use DateTime in IronPython

[亡魂溺海] 提交于 2019-11-30 13:51:53

Try adding a reference to mscorlib instead of System.Core. We changed the default hosting behavior at some point (2.0.1? 2.0.2?) so that this is done by default when hosting. You can do this from your hosting code with:

engine.Runtime.LoadAssembly(typeof(string).Assembly);

Just checked, and the problem is that you're trying to call Today as a method instead of a property. Try this instead (no need to add a reference to System.Core):

import clr
from System import DateTime
theDate = DateTime.Today
print theDate
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!