我的python程序的哪个部分导致错误

时间:2017-09-29 00:54:39

标签: python python-3.x

TypeError: 'float' object is not subscriptable

这是我的代码,但我不断收到错误 try { extractedId=vars.get("extracted_Id"); f= new FileOutputStream("D:/YourCSVFile.csv", **true**); p = new PrintStream(f); this.interpreter.setOut(p); print(extractedId); f.close(); } catch (Throwable ex) { log.error("Error in Beanshell", ex); throw ex; } 我已尝试搜索该错误的含义,但似乎没有任何答案适用于我的代码

2 个答案:

答案 0 :(得分:0)

这部分

round(rtoberounded[irounddigits])

和这部分

round(ffinalnumber[irounddigits])

rtoberoundedffinalnumber是一个浮点数,你不能像数组/列表一样调用它。

我认为你误导了documentation中的[, ndigits]部分。这意味着可选参数。

答案 1 :(得分:0)

reverse relation采用逗号round(rtoberounded, irounddigits)) 分隔的两个参数(数字位数):

  

回合数字 [, ndigits ])
  在小数点后将数字舍入为 ndigits 精度。

更改为:

rnumber = (round(ffinalnumber, irounddigits))

{{1}}