find sublist inside list

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon May 4 17:54:22 EDT 2009


En Mon, 04 May 2009 15:12:41 -0300, mzdude <jsanga at cox.net> escribió:

> substring isn't limited to 0..255
>>>> substring = "\0x%d\0x%d" % (257,257)
>>>> 'acaccgac'.replace("ac", substring)
> '\x00x257\x00x257\x00x257\x00x257cg\x00x257\x00x257'

This isn't what you think it is. Look carefully:

py> substring = "\0x%d\0x%d" % (257,257)
py> len(substring)
10
py> list(substring)
['\x00', 'x', '2', '5', '7', '\x00', 'x', '2', '5', '7']

-- 
Gabriel Genellina




More information about the Python-list mailing list