Slicing with python on a single line
I have data "line"
FF= ['123451234512345678901234512345', '123451234512345678901234512345']
I need to slice line 1-5, 6-10开发者_开发问答, 11, 12-22. How do I slice?
data= []
for col in FF:
data.append(col)
Something like:
a = [(s[:5], s[5:10], s[10], s[11:]) for s in FF]
With struct
.
>>> struct.unpack('5s5sc11s8x', '123451234512345678901234512345')
('12345', '12345', '1', '23456789012')
精彩评论