python中默认为浮动

python中默认为浮动,python,floating-point,int,dronekit-python,Python,Floating Point,Int,Dronekit Python,我正在编写一些使用GPS坐标的代码,但在使用Python2时遇到了麻烦。具体来说,我使用的是dronekit python库。这是我想做的一个例子 current_location = LocationGlobalRelative(x,y) dx = get_change_x(params) # float value to change x coordinate dy = get_change_y(params) # float value to change y coordinate new

我正在编写一些使用GPS坐标的代码,但在使用Python2时遇到了麻烦。具体来说,我使用的是dronekit python库。这是我想做的一个例子

current_location = LocationGlobalRelative(x,y)
dx = get_change_x(params) # float value to change x coordinate
dy = get_change_y(params) # float value to change y coordinate
new_x = current_location.lon + dx 
new_y = current_location.lat + dy
print new_x
print new_y

问题是新的x和y打印四舍五入值,如41.0。我知道这个问题可以通过用float()包装数字来纠正,但这看起来很笨拙。有没有办法告诉python所有的数字都应该被视为浮点数?

键入(current\u location.lat)给了您什么?它可能是一种行为类似于但不完全是浮动的东西。
print new_x
显示一个“.0”表明它是一个浮点,只是四舍五入。就此而言,这里的
dx
dy
也是什么?如果其中任何一个数字是
floats
,那么添加
int
值也会将它们强制为
floats
。你能为每个变量提供一些额外的测试吗?dcrosta,current_location.lat给出一个浮点值。dx和dy也是浮点数