UnicodeDecodeError in pyton 2.7

Posted by user2913962 on Stack Overflow See other posts from Stack Overflow or by user2913962
Published on 2013-10-24T03:50:57Z Indexed on 2013/10/24 3:53 UTC
Read the original article Hit count: 163

Filed under:

i try to write this code to process Arabic language by python

 import codecs
 file = codecs.open("C:\Python27\CCA_raw_utf8.txt","r","utf-8")
 text= file.read()
 ####################################

 print "\n "," --------------------------------------------"

 text=text[1:]
 words=text.split()

 for w in words:
    if w == unicode ("?????","utf-8"):
    print w

but it doesn't and take error " if w == unicode ("?????","utf-8"): UnicodeDecodeError: 'utf8' codec can't decode byte 0xc7 in position 0: invalid continuation byte "

why program gives this result and how we can correct that??

© Stack Overflow or respective owner

Related posts about python