Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找一种将 numpy 中的字符串数组转换为它们以十六进制表示的整数的方法。所以换句话说,数组版本:
int("f040", 16)
我可以通过调用 arr.astype(numpy.int32) 将字符串数组转换为整数 base-10,但我看不到任何明显的方法将它们转换为 base-16。有谁知道这样做的方法?
ar = ['f040', 'deadbeaf'] int_array = [int(a, 16) for a in ar] print int_array
output:
[61504, 3735928495L]