-8
這是我最近的代碼:Python的 - 指數超出範圍的錯誤
highest = {}
def reader():
myfile = open("scores.txt","r")
pre = myfile.readlines()
print(pre)
for line in pre :
print(line)
x = line.split(",")
a = x[0]
b = x[1]
c = len(b)-1
b = b[0:c]
highest[a] = b
這是完全回溯錯誤消息:
Traceback (most recent call last):
File "C:/Python34/my boto snaky/snaky.py", line 568, in gameLoop
reader()
File "C:/Python34/my boto snaky/snaky.py", line 531, in reader
b = x[1]
IndexError: list index out of range
一些scores.txt沒有逗號你行(「」)在他們。 另外,使用更好的標題。 – Sildar
這真的是你可以提出的最具描述性的標題嗎? – David
它說錯誤。 「列表索引超出範圍」。您在某些行中沒有逗號或缺少數據。 – Chris