Python reference
Heiko Wundram
heikowu at ceosg.de
Fri Jun 4 19:01:23 EDT 2004
Am Freitag, 4. Juni 2004 22:07 schrieb Reiner Block:
> <ironic>really great this documentation.</ironic> I'm searching and
> searching for two possibilities: test if a string is a number (integer) or
> to strip leading and trailing blanks. But it is impossible to find in the
> documentation how to do it. :-( Really: I never saw a worse docu as this
> one.
I don't really know how you're looking for what you need... Stripping leading
and trailing blanks is something that has to do with string manipulation. Go
and check: Library Reference -> String Type, and you'll soon find
str.strip().
About testing whether something is an integer: As always in Python, try to do
what you're doing, and test whether it succeeds.
y = "123a"
try:
x = int(y)
except ValueError:
print "Not a number."
HTH!
Heiko.
More information about the Python-list
mailing list