在原生Python try:
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="123456",
database="v21")
c = mydb.cursor()
lat = 36.8451995849609
lng = 54.428798675537
city = "Rasht"
state = "Gilan"
user = 70440675
arg = (user, state, city, lat, lng)
c.callproc('do1', arg)
mydb.commit()
except mysql.connector.Error as err:
print("Something went wrong: {}".format(err))
类型中,将float
强制转换为float
时似乎没有舍入:
str
但是,当将In [1]: foo = 0.24000000000000002
In [2]: print(str(foo))
0.24000000000000002
In [3]: print(repr(foo))
0.24000000000000002
强制转换为np.float64
时,会出现四舍五入的情况。
str
将In [4]: print(str(np.float64(foo)))
0.24
In [5]: print(repr(np.float64(foo)))
0.24000000000000002
强制转换为np.float64
时,舍入的逻辑是什么?