这个为啥报错了呢
import random
words_dict = {'高兴':'happy', '难过':'sad', '自由':'free', '得意':'proud',
'激动':'excited', '沮丧':'depressed', '平静':'calm', '生气':'angry',
'害怕':'fear', '勇敢':'brave'}
chinese_list = list(words_dict.keys())
def generate_options(index):
right_answer = words_dict[chinese_list[index]]
wrong_answers = list(words_dict.values())
del wrong_answers[index]
wrong_answer = random.sample(wrong_answers,3)
current_answers =[right_answer] + wrong_answer
current_answers = random.shuffle(current_answers)
return current_answers
options = []
for i in range(len(words_dict)):
option = generate_options(i)
options.append(option)
with open('./tmp/单词打卡.txt', 'w') as f:
for i in range(len(options)):
f.write('{}. {}的英文解释是?\n'.format(i+1, chinese_list[i]))
for j in range(4):
f.write('{}. {}\n'.format('ABCD'[j], options[i][j]))
f.write('\n')