I need to break a date value down to it's elements ( 8/23/2011
) which should be a piece of cake with
variable.split("/")
but it tells me that
'unicode' object has no attribute 'Split'
I tried encoding it as a different format:
date.encode("utf-8")
then it tells me that
'str' object has no attribute 'Split'
As A newbie to Python it seems like I've used split with strings before, but am not getting it to the right format or something. Or perhaps there is another way that is even easier.
Python is case-sensitive; you want split
, not Split
.
>>> x = u"8/23/2011"
>>> x.Split('/')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'unicode' object has no attribute 'Split'
>>> x.split('/')
[u'8', u'23', u'2011']
Python is case-sensitive. The method is called split
, not Split
.
unicode.split
starts with a lower-case s
and works fine:
>>> u'a,b'.split(u',')
[u'a', u'b']
精彩评论