Grep Equivalent for Python

Laurent Pointal laurent.pointal at limsi.fr
Wed Mar 14 09:40:44 EDT 2007


Steve Holden a écrit :
> Regular expressions aren't really needed here. Untested code follows:
> 
> for line in open('/proc/meminfo').readlines:
for line in open('/proc/meminfo').readlines():

>     if line.startswith("Memtotal:"):
>         name, amt, unit = line.split()
>         print name, amt, unit
>         break
> 
> regards
>  Steve



More information about the Python-list mailing list