class Question(object):
def __init__(self, question, options, answer, description, points):
self.question = question
self.options = options
self.answer = answer
self.description = description
self.points = points
def ask():
response = None
while response not in ("1", "2", "3", "4"):
response = raw_input(self.question).lower()
if response == self.answer:
print "right"
else:
print "wrong"
问题=? 答案=?在
我想让它检查我有多少问题,但我想从文本文件中添加问题和其他值。在
这就是我目前所掌握的,但是我真的很困惑如何从同一个文本文件中添加问题、答案、类别和分值。。在
文本文件示例琐事.txt公司名称:
^{pr2}$
分号分隔,即
读入并传递给对象:
^{pr2}$你知道有一个iterable列表,可以用来给问题赋值。这只是一种可能的解决办法。在
您还可以查看字典路径:
Creating a dictionary from a string
相关问题 更多 >
编程相关推荐