Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'loop.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:files': 0.09; 'aug': 0.13; "'r')": 0.16; 'f.read()': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'string': 0.17; 'wrote:': 0.17; 'string,': 0.17; 'header:In- Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'charset:iso-8859-15': 0.26; 'header:X-Complaints-To:1': 0.28; 'print': 0.32; 'to:addr:python-list': 0.33; 'subject:?': 0.35; 'received:org': 0.36; 'but': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'ave': 0.65; 'oscar': 0.84; 'subject:read': 0.84; 'do:': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Oscar Benjamin Subject: Re: What do I do to read html files on my pc? Date: Tue, 28 Aug 2012 13:31:52 +0100 References: <1c7cd833-b6ad-4a17-8ffe-a0ce20c8f400@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: cpc1-aztw8-0-0-cust1455.18-1.cable.virginmedia.com In-Reply-To: User-Agent: Groundhog Newsreader for Android X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1346157132 news.xs4all.nl 6970 [2001:888:2000:d::a6]:39315 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28017 On Tue, 28 Aug 2012 03:09:11 -0700 (PDT), mikcec82 wrote: > f = open(fileorig, 'r') > nomefile = f.read() > for x in nomefile: > if 'XXXX' in nomefile: > print 'NOK' > else : > print 'OK' You don't need the for loop. Just do: nomefile = f.read() if 'XXXX' in nomefile: print('NOK') > ** > But this one works on charachters and not on strings (i.e.: in this way I h= > ave searched NOT string by string, but charachters-by-charachters). Oscar