python数学库将弧度作为三角函数的输入,
所以一定要把B的值转换成弧度
它可以通过
B=math.radians(B)
最终代码:
import math
def radius (B):
B=math.radians(B) #converting into radians
a = 6378.137 #Radius at sea level at equator
b = 6356.752 #Radius at poles
c = (a**2*math.cos(B))**2
d = (b**2*math.sin(B))**2
e = (a*math.cos(B))**2
f = (b*math.sin(B))**2
R = math.sqrt((c+d)/(e+f))
return R