- 帖子
- 10
- 精华
- 0
- 积分
- 47
- 阅读权限
- 10
- 注册时间
- 2017-1-27
- 最后登录
- 2017-2-11
|
本帖最后由 felixfunky 于 2017-2-6 06:13 编辑
from random import randint
name = raw_input('enter your name: ')
f = open('F:\python27\game.txt')
lines = f.readlines()
f.close()
scores = {}
for l in lines:
s = l.split()
scores[s[0]] = s[1:]
score = scores.get(name)
if score is None:
score = [0, 0, 0]
报错了。。。。请问这段代码问题出在哪里。。。反复对照,和示例上面一模一样的
Traceback (most recent call last):
File "F:/python27/lesson41.1.py", line 12, in <module>
scores[s[0]] = s[1:]
IndexError: list index out of range
|
|