1
mrluanma Jul 15, 2013
>>> [int(x.split(None, 1)[0]) for x in ['128 MB', '27 PERCENT']]
[128, 27] |
3
mrluanma Jul 15, 2013
@ioiioi
>>> help("".split) Help on built-in function split: split(...) S.split([sep [,maxsplit]]) -> list of strings Return a list of the words in the string S, using sep as the delimiter string. If maxsplit is given, at most maxsplit splits are done. If sep is not specified or is None, any whitespace string is a separator and empty strings are removed from the result. |
4
ToughGuy Jul 16, 2013
import re
[map(int, re.findall(r'\d+', x)) for x in ['128 MB', '27 PERCENT']] 新手... |