如果我运行以下代码,它无法识别数组中的几个数字,例如0.1
,即使它0.1
在打印时看起来像是在数组中。
import numpy as np
pH = 0.1
print(np.linspace(0.0, 2.9, num=30))
if pH in np.linspace(0.0, 2.9, num=30):
print("it doesn't recognize 0.1")
pH = 0.3
if pH in np.linspace(0.0, 2.9, num=30):
print('however it does recognize 0.3')
输出:
[0. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1. 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2. 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9]
however, it does recognize 0.3