【问题标题】:Getting C# Int64 in Python在 Python 中获取 C# Int64
【发布时间】:2018-01-04 12:59:55
【问题描述】:

我必须在 Python 中获取一个 Int64 对象。我的代码如下所示:

from System import Int64
l = Int64.Parse('123')
print(l, type(l))

但它返回:123 <class 'int'>

当我对 DateTime c# 对象执行相同操作时,它返回了正确的类型:<class 'System.DateTime'>

那么为什么 Python 将 Int64 C# 对象转换回它自己的 int 类?

我正是需要这种类型,因为我将它发送到外部程序,否则会失败。

非常感谢。

【问题讨论】:

  • 我不确定原生 python 中是否存在 int64。也许你想使用 numpy??
  • long (Int64) 是一个原语;我会 expect python 将其映射到它自己最接近的原语...?

标签: c# python types long-integer int64


【解决方案1】:

想了个办法,不过是个不折不扣:

Int64.__new__(Int64, value)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-04
    • 1970-01-01
    • 1970-01-01
    • 2016-07-06
    • 1970-01-01
    相关资源
    最近更新 更多