初学者在这里。我正在创建测验项目,我有字符串:
s = "1. You are _____ me.
A) older B) oldest C) older than D) older then
2. New York is _____ Paris.
A) dirty B) dirtier than C) the dirtiest D) dirtier
3. Prague is one of the _____ cities in Europe,
A) most beautiful B) more beautiful
C) beautiful D) the most beautiful
4. How many children _____ they _____?
A) have / got B) have / get
C) does / got D) has / got"
我需要切片它测试编号。结果必须看起来像这样:
result = {
"test_number": test number,
"question": question text,
"options": [test options],
}
1条答案
按热度按时间wj8zmpe11#
你可以从字符串
s
中提取信息,方法是将它拆分成单独的行,然后解析每一行以提取相关信息。这段代码将创建一个字典列表,其中每个字典代表一个测试,并包含测试编号、问题文本和选项列表。