[docs] how to using it?
Georg Brandl
georg at python.org
Sun Oct 17 08:25:47 CEST 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Am 05.10.2010 16:47, schrieb 古志磊:
> Hi:
>
> “|a[i:j, k:l]|” in the python 2.5 documentation.
>
> But I don’t know how to using it.
>
> There is a error if I run this codes:
>
>>>> a = "abcdefghigklmn"
>
>>>> a[1:3, 4:7]
>
> Traceback (most recent call last):
>
> File "<stdin>", line 1, in <module>
>
> TypeError: string indices must be integers
>
>
>
> Please give me a right code .
Hi Guzl,
while this syntax itself is supported in Python, it is not defined or supported by
any of the core types. If you want to get different ranges of a string
concatenated,
you'll need to do this explicitly:
a[1:3] + a[4:7]
regards,
Georg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
iEYEARECAAYFAky6lusACgkQN9GcIYhpnLDRZQCfSPoGrdKA9otxHS5ObtT3NeXk
nm4AnAg6cDkt3mlZIwVud36B5+E4NgJb
=NtmF
-----END PGP SIGNATURE-----
More information about the docs
mailing list