2012-03-27 135 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])