【问题标题】:Loop through parameter inputs循环参数输入
【发布时间】:2023-01-05 22:58:49
【问题描述】:

我想为输入运行具有不同值的相同命令,但不知道如何循环它们。我正在使用 TroPyCal 模块进行热带气旋分析。

我想要做的是:

basin.get_season(1970)
basin.get_season(1971)
basin.get_season(1972)

1970-2020 年以此类推。但不确定如何为此创建一个循环(或者如果可能的话)。

【问题讨论】:

  • 您忘记包括您尝试编写这样一个循环(这是绝对可能的)。

标签: python loops


【解决方案1】:

使用 for 循环遍历 1970 年到 2020 年并调用 get_season:

for year in range(1970, 2021):
    basin.get_season(year)

【讨论】:

    猜你喜欢
    • 2021-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-28
    • 1970-01-01
    • 1970-01-01
    • 2012-07-29
    • 2019-05-24
    相关资源
    最近更新 更多