微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决** 之后的 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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。