My database looks like this
framework
I took one of the name age nr, made array, as long as the data taken by the existence of str type, then take out the data, all converted to str type, that is, array array elements are all str, regardless of the database definition is not int type.
Then the problem comes, the data removed into the formula for the calculation of the time, it will not match the type, this is used asype()
The code is as follows
import pymysql import numpy as np conn = (host='39.106.168.84', user='xxxxxx', password='xxxxxx', port=3306, db='flask_topvj_net') cur = () sql = "SELECT `name`, `age`,`nr` FROM `student` WHERE 1" (sql) u = () u=(u) () print(u) #a=u[:,1]*5 #b=u[:,2]*5# Error Demonstration a=u[:,1].astype()*5 b=u[:,2].astype()*5 print(a) print(b)
in the end
You can see that the second and third columns of the array are multiplied by 5. The calculation was successful.
This is the whole content of this article.