What's the difference between str and 'hello' ?
hong Yu
hyu163 at gmail.com
Thu May 19 05:27:34 EDT 2005
I am new to python.
I was confused:
>>> a = list('hello')
>>> a
['h', 'e', 'l', 'l', 'o']
I want to combine the items in the list into a string.
So:
>>> ''.join(a)
'hello'
but:
>>> str.join(a)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: descriptor 'join' requires a 'str' object but received a 'list'
So why TypeError raised?
and
What's the difference between str and 'hello' ?
Thanks a lot.
More information about the Python-list
mailing list