index-error

    0熱度

    1回答

    我是一個初學者在python,目前正在執行一段代碼,但它會引發以下錯誤。我盡我所能解決但無法做到這一點。請幫幫我。代碼如下。 continue num_snps_skipped += 1 samp_id = sline[id_index] ref_allele = sline[ref_allele_index] tum_allele = sline[tum_

    -2熱度

    1回答

    使用python 2.7x: 我已經通過其他問題搜索,但找不到類似於我的功能。我正在寫一個Excel電子表格。變量a在整個程序的其他地方不使用。我已經嘗試將全局變量放在函數之前,在函數內部,將函數添加到如下所示的函數中,從for循環更改爲while循環等,幾乎所有內容都是其他文章所建議的,但不幸的是它們不起作用。 難道是因爲我使用了一個數組,它也影響了代碼? 我不斷收到IndexError:這個w

    1熱度

    2回答

    我真的很困惑,現在: >>> string = "some string" >>> string[100:105] '' >>> string[100] Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: string index out of range 爲什

    -1熱度

    2回答

    自從週三for循環在Python(2.7)(在Windows 10中)中無法正常工作。請參閱截圖。它跳過第一個和第二個元素(索引0和1)。一個類似的while循環工作正常。

    0熱度

    4回答

    我有一個列表中的名字,我想刪除一個可選的名字,但行 if newArray[i]==a: 低於它說:「IndexError:列表索引超出範圍」 newArray = ['John','Alex','Sophia','Rick'] a = str(raw_input('Type your name if you want to delete : ')) if a in newArray:

    0熱度

    1回答

    目前我使用下面的代碼: import urllib from bs4 import BeautifulSoup import codecs file_obj = open("E:\\Sport_Cricket.txt", "r+") links_str = file_obj.readlines() c=1 for j in links_str: url=j.rstrip('

    0熱度

    1回答

    所以,這是我的問題。根據條件,我試圖去查看嵌套列表並刪除一些元素。問題是,當一個元素被刪除,這將改變列表的長度,反過來,創建錯誤: IndexError: list index out of range 這是我的代碼: a = [[[1] * 2 for i in range(n)] for j in range(p)] for y in range(p): for x

    0熱度

    1回答

    我知道這個問題已經被多次詢問過,但是我已經重複檢查了編號並且錯誤仍然出現。我想知道是否還有其他明顯的錯誤。 with open('imagefile.csv', newline='') as csvfile: imagelog = csv.reader(csvfile, delimiter=',', quotechar='|') for row in imagelog:

    -2熱度

    1回答

    我只是wan't來計算Ic[n][0 until 12]總和,並將其保存在NW =名單()的總和,但...這是行不通的。我收到一個錯誤,告訴我"list index is out of range"。我現在不怎麼解決它。她的是代碼: for n in range(0, 12): for r in range(0, 12): nw[n] += Ic[n][r] p

    1熱度

    2回答

    我正試圖在數組「out_der」的「out_max」中找到每個元素的位置。我想將每個值的位置索引存儲在名爲「out_pos」的數組中。 「out_der」是400x300x60x27陣列,「out_max」是400x300x60陣列。 「out_pos」也應該是400x300x60陣列。我嘗試將「out_der」轉換爲列表並使用.index(),但那不起作用(因爲列表中只有400個元素)。這是我目