Use:
a = ['Tests run: 1', ' Failures: 0', ' Errors: 0']
d = {}
for b in a:
i = b.split(': ')
d[i[0]] = i[1]
print d
returns:
{' Failures': '0', 'Tests run': '1', ' Errors': '0'}
If you want integers, change the assignment in:
d[i[0]] = int(i[1])
This will give:
{' Failures': 0, 'Tests run': 1, ' Errors': 0}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…