numpy.zeros() converts string format to numpy.float64

y = numpy.zeros(shape=(1, 2))
print(y[0][0])
<class 'numpy.float64'>
y[0][0] = '12'
print(y[0][0])

y[0][0] = 'handlesdf'
print(y[0][0]) #Error
When declaring y = numpy.zeros(shape=(1, 2)), the element type in y is float64 by default, and then the string is automatically converted to float64


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324678394&siteId=291194637