Novice: replacing strings with unicode variables in a list
aine_canby at yahoo.com
aine_canby at yahoo.com
Wed Dec 6 04:27:00 EST 2006
More information about the Python-list mailing list
Wed Dec 6 04:27:00 EST 2006
- Previous message (by thread): Novice: replacing strings with unicode variables in a list
- Next message (by thread): Novice: replacing strings with unicode variables in a list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
Im totally new to Python so please bare with me.
Data is entered into my program using the folling code -
str = raw_input(command)
words = str.split()
for word in words:
word = unicode(word,'latin-1')
word.encode('utf8')
This gives an error:
File "C:\Python25\lib\encodings\cp850.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\x94' in
position 0
: character maps to <undefined>
but the following works.
str = raw_input(command)
words = str.split()
for word in words:
uni = u""
uni = unicode(word,'latin-1')
uni.encode('utf8')
so the problem is that I want replace my list with unicode variables.
Or maybe I should create a new list.
I also tried this:
for word in words[:]:
word = u""
word = unicode(word,'latin-1')
word.encode('utf8')
print word
but got TypeError: decoding Unicode is not supported.
What should I be doing?
Thanks for your help,
Aine.
- Previous message (by thread): Novice: replacing strings with unicode variables in a list
- Next message (by thread): Novice: replacing strings with unicode variables in a list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list