我有一系列的答案,包括标记。如何拆分文本数组?
语法 - 。?[“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"]
我需要为每个回答这些拆分,并提取标志我怎么办呢
以下是一些具体的文档你对字符串进行操作,所以第一站将是[S特林方法](http://docs.python.org/library/stdtypes.html#string-methods),特别是'split'方法。您还在使用一个列表,所以请参阅['for'语句](http://docs.python.org/tutorial/controlflow.html#for-statements)和/或[list comprehensions](http:/ /docs.python.org/tutorial/datastructures.html#list-comprehensions)。 – 2012-02-05 13:44:26