removing characters before writing to file

Stefan Neumann stefan.neumann at freiheit.com
Thu Feb 9 10:09:22 EST 2006


eight02645999 at yahoo.com wrote:
> hi
> i have some output that returns a lines of tuples eg
>
> ('sometext1', 1421248118, 1, 'P ')
> ('sometext2', 1421248338, 2, 'S ')
> and so on
> ....
>

If the braces are always at the begining and at the end of the string,
you could also use:

	>>> "('sometext1', 1421248118, 1, 'P ')"[1:-1]
	"'sometext1', 1421248118, 1, 'P '"

cheers
	Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20060209/984095a2/attachment.sig>


More information about the Python-list mailing list