On 29/12/2013 13:36, Ulrich Goebel wrote:
Hallo,
I have a unicode string s, for example u"abc", u"äöü", u"123" or
something else, and I have to find out wether
1. s is not empty and contains only digits (as in u"123", but not in
u"3.1415")
or
2. s is empty or contains only whitespaces
For all other cases I would assume a "normal" unicode string in s,
whatever that may be.
For the first case it could be s.isdigit(), s.isnumeric() or
s.isdecimal() - but which one is the best?
For the second case it should be s.isspace(), but it works only on
strings, not on unicode strings?
Many thanks for any help!
Ulrich
This depends on whether you are using python 2 or 3. In the latter all
strings are unicode. Please see
http://docs.python.org/X/library/stdtypes.html#string-methods where X is
2 or 3. You might also want to look at
http://docs.python.org/3.3/howto/unicode.html
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor