slice indices must be integers or None or have an __index__ method

slice indices must be integers or None or have an index method

刚开始的写法

cleaned_data = cleaned_data[0:len(cleaned_data)*0.9]

错误原因是浮点数不能当数组或者元组的下标

正确写法,转成int就可以了,试过用round替换int但是也没起作用

cleaned_data = cleaned_data[0:int(len(cleaned_data)*0.9)]

你可能感兴趣的:(slice indices must be integers or None or have an __index__ method)