方法1:在变量后直接加上 0 即可。
import numpy as np
a = np.array([True, False])
print(a)
print(a + 0)
方法2:使用类型转换
import numpy as np
a = np.array([True, False])
print(a)
a.astype(int)
print(a)
参考链接:
https://blog.csdn.net/u_7890/article/details/85058365
https://blog.csdn.net/scut_salmon/article/details/78798128