Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #28017

Re: What do I do to read html files on my pc?

From Oscar Benjamin <oscar.j.benjamin@gmail.com>
Subject Re: What do I do to read html files on my pc?
Date 2012-08-28 13:31 +0100
References <1c7cd833-b6ad-4a17-8ffe-a0ce20c8f400@googlegroups.com> <dd711c0c-19ec-4d3d-bfc4-93ff209ec7e4@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.3897.1346157132.4697.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, 28 Aug 2012 03:09:11 -0700 (PDT), mikcec82 
<michele.cecere@gmail.com> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

What do I do to read html files on my pc? mikcec82 <michele.cecere@gmail.com> - 2012-08-27 03:59 -0700
  Re: What do I do to read html files on my pc? Chris Angelico <rosuav@gmail.com> - 2012-08-27 21:58 +1000
  Re: What do I do to read html files on my pc? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-27 13:05 +0100
  Re: What do I do to read html files on my pc? mikcec82 <michele.cecere@gmail.com> - 2012-08-27 06:51 -0700
    Re: What do I do to read html files on my pc? Joel Goldstick <joel.goldstick@gmail.com> - 2012-08-27 10:21 -0400
    Re: What do I do to read html files on my pc? Chris Angelico <rosuav@gmail.com> - 2012-08-28 00:41 +1000
    Re: What do I do to read html files on my pc? Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-08-27 18:57 +0200
  Re: What do I do to read html files on my pc? mikcec82 <michele.cecere@gmail.com> - 2012-08-28 03:09 -0700
    Re: What do I do to read html files on my pc? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-08-28 13:31 +0100
  Re: What do I do to read html files on my pc? Peter Otten <__peter__@web.de> - 2012-08-28 17:38 +0200
  Re: What do I do to read html files on my pc? mikcec82 <michele.cecere@gmail.com> - 2012-08-29 03:22 -0700
  Re: What do I do to read html files on my pc? Umesh Sharma <usharma01@gmail.com> - 2012-08-29 05:00 -0700

csiph-web