赞
踩
import numpy as np
a = np.array(3)
b = np.array('3')
print(type(a), a)
print(type(b), b)
print("*********************")
print(type(a.item()), a.item()) # <class 'int'>
print(type(b.item()), b.item()) # <class 'str'>
print("*********************")
print(type(a.tolist()), a.tolist())
print(type(b.tolist()), b.tolist())
print("*********************")
print(type(int(a)), int(a))
print(type(str(b)), str(b))
<class 'numpy.ndarray'> 3
<class 'numpy.ndarray'> 3
*********************
<class 'int'> 3
<class 'str'> 3
*********************
<class 'int'> 3
<class 'str'> 3
*********************
<class 'int'> 3
<class 'str'> 3
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。