Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.109.133.86.MISMATCH!newsfeed.xs4all.nl!newsfeed3.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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'assuming': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'temp': 0.16; 'typo': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'split': 0.19; '(in': 0.22; 'header:User-Agent:1': 0.23; 'parse': 0.24; 'header:X-Complaints-To:1': 0.27; 'code': 0.31; 'subject:numbers': 0.31; 'subject:that': 0.31; 'there,': 0.34; 'but': 0.35; 'charset:us-ascii': 0.36; 'example,': 0.37; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'worry': 0.60 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re: Parsing an html line and pulling out only numbers that meet a certain criteria Date: Thu, 12 Sep 2013 10:36:24 +0000 (UTC) References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 174.32.174.36 User-Agent: XPN/1.2.6 (Street Spirit ; Linux) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1378982206 news.xs4all.nl 15897 [2001:888:2000:d::a6]:59361 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:54048 On 11/9/2013 23:03, Cory Mottice wrote: > I am using line.rfind to parse a particular line of html code. For example, this is the line of html code I am parsing: > > 79°Lo 56° > > and this is the code I use to split the line to (in this case) pull out the '79'. > > position0 = line.rfind('{}'.format(date1.strftime("%a"))) > if position0 > 0 : > self.high0 = lines[line_number + 4].split('')[0].split('">')[-1] > > Now I need to only pull out that number if it is >=94 and <=37. If it does not meet this criteria, I don't want anything to happen. Any ideas? Thank you in advance! Since no integer is both >=94 and <=37, you'd never have to worry about it. But assuming there's a typo there, temp = lines[line_number + 4......... if 94 <= int(temp) <= 37: self.high0 = temp -- DaveA