python:将numpy数组数据类型从int64转换为int

问题描述:

我对 python 有点陌生,我在另一个程序 (ABAQUS) 中使用 python 模块.然而,这个问题完全与 python 相关.

I am somewhat new to python and I am using python modules in another program (ABAQUS). The question, however, is completely python related.

在程序中,我需要创建一个整数数组.该数组稍后将用作 ABAQUS 中定义的函数的输入.问题与整数的数据类型有关.在数组中,整数的数据类型为int64".但是,当我将数组输入到所需的函数时出现以下错误:

In the program, I need to create an array of integers. This array will later be used as an input in a function defined in ABAQUS. The problem is to do with the data type of the integers. In the array, the integers have data type 'int64'. However, I am getting the following error when I input the array to the desired function:

ABAQUS 接口仅支持 INT、FLOAT 和 DOUBLE(如果标准 long 是 64 位,则使用类型代码为 int 的多数组)"

"Only INT, FLOAT and DOUBLE supported by the ABAQUS interface (use multiarray with typecode int if standard long is 64 bit)"

我不需要 ABAQUS 的帮助.如果我在 python 中将数据类型转换为int",那就足够了.我以为我可以简单地使用 int() 函数来转换数据类型.这没有用.任何建议将不胜感激.谢谢大家.

I do not need assistance with ABAQUS. If i convert the data type to 'int' in python, that would suffice. I thought that I could simply use the int() function to convert the data type. This did not work. Any suggestions will be highly appreciated. Thank you all.

@J.F.塞巴斯蒂安的回答:

@J.F. Sebastian's answer:

a.astype(numpy.int32)