** 之后的 float 对象参数必须是映射,而不是 int

问题描述

我在 VScode 上使用 Jupyter 笔记本。 我有带有 .py 定义的 python 脚本。

python 脚本包含一个我需要的定义,

def pressure2depth (P,L,Del):
    # calculate depth from pressure sensor
    # pressure (P) : in dbar
    # latitude (L) : degree
    # Geopotential anomaly (Del) : dyn meteres
    X = math.sin(L / 57.29578)*math.sin(L / 57.29578)
    GR = 9.780318 * (1.0 + (5.2788*(10**-3) + (2.36*(10**-5)) * X) * X) + (1.092*(10**-6)) * P
    DepthTerm = ((( (-1.82*(10**(-15))) * P + 2.279*(10**(-10))) * P - 2.2512*(10**(-5)) ) * P + 9.72659) * P
    DEPTH = DepthTerm / GR + Del / 9.8
    return DEPTH

但是,当我将此函数导入 Jupiter notebook 环境并使用它时,它返回以下错误

float object argument after ** must be a mapping,not int.

但是我将定义复制并粘贴到 Jupyter Notebook 上并运行它,它可以正常工作。

我该如何解决这个问题?

解决方法

您传递的值格式不正确。

pressure2depth(2123,234,324) # int or float are passed here