En Sun, 18 Feb 2007 07:04:27 -0300, bryan rasmussen  
<[EMAIL PROTECTED]> escribió:

> the following is returning -1:
>
> x = open("latvian.txt",'r')
> x1 = x.read()
> print x1.find("LAYOUT")

> the encoding of the file is Unicode, I am able to return instances of
> individual characters but not whole words.

"Unicode" can't be the encoding. It's better to convert from bytes to  
unicode objects just after reading, and then work on Unicode always.

x = open("latvian.txt",'r')
x1 = x.read().decode() # or .decode("utf8") or the right encoding for the  
file
print type(x1) # should print <type 'unicode'>
x1.find(u"LAYOUT")

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to