string.find does not work in file

Roman Suzi rnd at onego.ru
Tue Jun 17 11:46:02 CEST 2003


On Tue, 17 Jun 2003, [iso-8859-15] Wolfram Strauъ wrote:

> Hi,
> I have a problem to run the following lines in a file.
> >
> import string
> f = open('in.txt')
> for l in f.readlines():
> 	print string.find(l, '"\n')
> <
> 
> In my python shell (version 2.2.2) on a W2000 system the code finds all 
> lines with the pattern. But running the same code as a python scipt in a 
> shell it does not find any pattern.

Maybe the problem is that there are really no \n right after '"'.
For example, the text file uses CRLF line endings.
Try to find '"\r\n'
 
> If you have any idea, please let me know. Thanks Wolfram
> 
> 

Sincerely yours, Roman A.Suzi
-- 
 - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru -
 






More information about the Python-list mailing list