Parsing string into fixed-width pieces
Kragen Sitaker
kragen at pobox.com
Tue Mar 19 13:51:10 EST 2002
"Johnson, Brad" <brad-g-johnson at uiowa.edu> writes:
> I'm new to Python and have been combing the documentation and the message
> archive here for information on splitting a string into fix-width pieces. I
> assume their is an easy way to do this, I just don't seem to be able to find
> it in the reference material. Any suggestions?
Is this to unpack some fixed-width record format? The struct module
is used for fixed-width record formats:
>>> import struct
>>> struct.unpack('3s4s3s', 'asdfghijkl')
('asd', 'fghi', 'jkl')
HTH.
More information about the Python-list
mailing list