Как разбить текстовый массив? - PullRequest
0 голосов
/ 05 февраля 2012

У меня есть массив ответов, включая оценки.

Синтаксис - ["ANSWER1 | MARK1, ANSWER2 | MARK2 ...]

answers = ["Human machine interface for lab abc computer applications|3",
             "A survey of user opinion of computer system response time|4",
             "The EPS user interface management system|2",
             "System and human system engineering testing of EPS|1"]

Мне нужно разделить их и извлечь оценки для каждого ответа. Как мне это сделать?

1 Ответ

5 голосов
/ 05 февраля 2012

Например:

>>> [a.split("|") for a in answers]
[['Human machine interface for lab abc computer applications', '3'], 
['A survey of user opinion of computer system response time', '4'], 
['The EPS user interface management system', '2'], 
['System and human system engineering testing of EPS', '1']]
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...