【问题标题】:Adding a string to an empty list in Zapier将字符串添加到 Zapier 中的空列表
【发布时间】:2018-11-27 05:34:46
【问题描述】:

我正在尝试将字符串添加到 Zapier 代码中的空列表中。

我已经在本地尝试了代码并且它可以工作。我不明白为什么它在 Zapier 内部不起作用。这是代码

output = []
if (input_data[0]=="true"): output.append("string")

这是错误

Traceback (most recent call last):
File "/tmp/tmpEeICti/usercode.py", line 10, in the_function
if (input_data[0]=="true"): output.append("Situationsplan")
KeyError: 0 

【问题讨论】:

    标签: zapier


    【解决方案1】:

    David 来自 Zapier 平台团队。

    input_data 是一个dict,但您像访问数组一样访问它。没有'0' 键,所以你得到了那个错误。 input_data 中的键是在代码输入的正上方创建的,因此请随意编辑该表单以获取不同的数据。

    此外,output 需要是 dicts 的数组,因此一旦实际运行,["Situationsplan"] 的值将导致错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-09
      • 2011-09-10
      • 2018-08-12
      • 2014-07-05
      • 2020-08-15
      • 2015-10-21
      相关资源
      最近更新 更多