2012-03-27 137 views

回答

2

尽管这个问题是完全错误的,这里的一些解决方案:

import re 
x = ['P: 7678643 F: 123456 E: [email protected]'] 
Split = re.split(' ', x[0]) 
y = [] 
for i in range(0, len(Split), 2): 
    y.append(Split[i] + Split[i+1]) 
1

。在你的代码示例中没有字典。根据你的代码,我会使用正面表达式和负面后视。

x = ['P: 7678643 F: 123456 E: [email protected]'] 
y = re.split('(?<!:)\s', x[0])