【发布时间】:2021-05-10 03:09:58
【问题描述】:
我正在尝试在 python 3.9 中制作一个测验制作器和加载器,我想知道如何保存问题和答案列表。这样您就可以创建一个列表,然后将其保存到一个文件中并加载它来回答它。
questions = [
input("Enter question 1: "),
input("Enter question 2: "),
input("Enter question 3: "),
input("Enter question 4: "),
input("Enter question 5: "),
input("Enter question 6: "),
input("Enter question 7: "),
input("Enter question 8: "),
input("Enter question 9: "),
input("Enter question 10: "),
]
【问题讨论】:
-
您可以使用任何文件格式,如 txt、csv 等。也可以使用 pickle:stackoverflow.com/questions/11218477/…
-
根据用例可能不安全的方式使用 Pickle。 stackoverflow.com/q/21752259/4440330
-
只是为了测验而已。
标签: python python-3.x python-3.9