[Tutor] Editing values from a dictionary
Ben Finney
ben+python at benfinney.id.au
Wed Feb 26 18:29:28 CET 2014
Bob Williams <linux at barrowhillfarm.org.uk> writes:
> In [3]: print metadata["artist"]
> [u'The Incredible String Band']
>
> I now want to pass that string to another program, but I want to strip
> off the leading [u' and the trailing '].
You may be assuming that ‘metadata["artist"]’ is a text string; I
suspect it is not.
Try ‘type(metadata["artist"])’, to get Python to tell you what the type
of that object is.
--
\ “Those who write software only for pay should go hurt some |
`\ other field.” —Erik Naggum, in _gnu.misc.discuss_ |
_o__) |
Ben Finney
More information about the Tutor
mailing list