如何修复“列表分配索引超出范围”

时间:2019-04-30 07:09:20

标签: python python-3.x

我正在尝试使用计数器和列表来输入尺寸然后存储它,但是我被

击中了

列表分配索引超出范围

即使您将范围设置为计数器的值

array = ["a","b","c","d"]
inputJson = {"a":1,"z":2}

if all(k in array for k in inputJson):
    print("Ok..")
else:
    print("Error!")

# --> Error!

1 个答案:

答案 0 :(得分:0)

    for (int index = 0; index < image.size(); index++) {
        Log.d("Upload request", "requestUploadSurvey: survey image " + index + "  " + image.get(index));
        File file2 = new File(image.get(index));
        RequestBody surveyBody = RequestBody.create(MediaType.parse("image/*"), file2);
        multipartTypedOutput[index] = MultipartBody.Part.createFormData("imageFiles[]", file2.getPath(), surveyBody);
    }