Zapier上的Python代码出错

Zapier上的Python代码出错,python,zapier,Python,Zapier,我编写了这个简单的脚本来使用ShadowRun5e规则进行可用性测试,该规则基于使用Zapier的google表单中的数据。但是,当我运行这个程序时,Zapier返回了一个错误。一切似乎都井然有序,我做错了什么 import random itempoolgot = int(input_data.get('itempool')) opposedpoolgot = int(input_data.get('opposedpool')) itempoolloops = 0 itemhits =

我编写了这个简单的脚本来使用ShadowRun5e规则进行可用性测试,该规则基于使用Zapier的google表单中的数据。但是,当我运行这个程序时,Zapier返回了一个错误。一切似乎都井然有序,我做错了什么

import random 

itempoolgot = int(input_data.get('itempool'))
opposedpoolgot = int(input_data.get('opposedpool'))

itempoolloops = 0
itemhits = 0
opposedpoolloops = 0
opposedhits = 0
while (itempoolloops <= itempoolgot):
    diceresult = random.randint(1, 6)
    itempoolloops = itempoolloops + 1
    if diceresult >=5:
        itemhits = itemhits + 1

while (opposedpoolloops <= opposedpoolgot):
    diceresult = random.randint(1, 6)
    opposedpoolloops = opposedpoolloops + 1
    if diceresult >=5:
        opposedhits = opposedhits + 1
return {
    'opposedhits': opposedhits, 'itemhits' : itemhits
}
随机导入
itempoolgot=int(输入数据.get('itempool'))
oppositedpoolgot=int(输入_data.get('oppositedpool'))
itempoolloops=0
itemhits=0
反向池循环=0
反向点击率=0
而(itempoolloops=5:
itemhits=itemhits+1
而(反向池循环=5:
反向点击=反向点击+1
返回{
'oppostedhits':oppostedhits,'itemhits':itemhits
}
这是错误消息“Bargle.We在创建运行python时出错”:(错误: 您的代码有错误!”

我已经运行了另一个代码,它只生成一个随机数,它工作正常,可能是while循环出了问题


编辑2:通过跳过Zapier中的测试步骤,我发现了以下错误:发送到代码“Run Python”失败:您的代码有错误!回溯(最近一次调用):文件“/tmp/tmpQdoNPW/usercode.py”,第16行,在函数diceresult=random.randint(1,6)NameError:全局名称“random”未定义

我确实“将random作为random导入”一开始,它就成功了。

“Zapier返回一个错误”->我们对这个问题的了解与您在问题中所写的一样多。因此,我们无法读懂您的心思并“知道”错误是什么。请在您的帖子中包含确切的错误消息。这就是我得到的“Bargle。我们在创建运行python时遇到了一个错误。”(错误:您的代码有一个错误!)我认为Zapier可能不允许while循环,因为我运行的代码没有while循环,它工作得很好。Zapier在编写错误消息方面出了名的不好。有可能输入数据没有这两个值吗?如果将
None
传递到
int()
它将引发异常。我发现代码中有一个输入错误,但仍然得到一个错误。