【发布时间】:2019-12-13 20:00:09
【问题描述】:
我正在编写一个从 .txt 文件中读取问题的程序。问题用破折号“-----”包围 问题后面还有四个可能的正确答案,然后是答案。我不知道如何将这些分开打印。该文件超过 10,000 行,我需要能够一次打印一个问题,但我不确定如何指定仅在破折号之间读取。
文本示例:
---------------------------------------------------------------------------
#1010 How tall is the actor Verne Troyer, famous for his role as Mini-me
in the Austin Powers films?
---------------------------------------------------------------------------
*36 inches
*32 inches
*24 inches
*35 inches
Answer: 32 inches
---------------------------------------------------------------------------
#1011 Who auditioned for the role of James Bond in 1969 but was turned
down for being too tall?
---------------------------------------------------------------------------
*John Cleese
*Peter Snow
*Simon Dee
*Christopher Lee
Answer: Peter Snow
【问题讨论】:
-
欢迎来到 StackOverflow!您能否提供一个minimal reproducible example 您的工作,并准确指出哪里没有成功?
-
你为解决这个问题做了什么?