Regex Python Help

Vincent Vande Vyvre vincent.vande.vyvre at telenet.be
Tue Mar 24 15:38:54 EDT 2015


Le 24/03/2015 20:22, Gregg Dotoli a écrit :
> Thank you! But
>
> The print error is gone, but now the script quickly finishes and doesnt walk
> the OS tree or search.
>
> Gregg
>
>
>
> On Tuesday, March 24, 2015 at 2:14:32 PM UTC-4, Gregg Dotoli wrote:
>> I am creating a tool to search a filesystem for one simple string.
>> I cannot get the syntax correct.
>> Thank you in advance for your help.
>>
>> import sys
>> import re
>> import os
>> path='/'
>> viewfiles=os.listdir(path)
>> for allfiles in viewfiles:
>>      file= os.path.join(path, allfiles)
>> text=open(file, "r")
>> for line in text:
>>      if re.match("DECRYPT_I", line):
>>          print line,
>>
>> ----------------------------------------------------------
>> This should search every file for the simple regex "DECRYPT_I"
>> This is from the root down.
>>
>> The error is:
>>
>> SyntaxError: Missing parentheses in call to 'print'
>>
>> Please help.
>> Gregg Dotoli
Your indentation is wrong.

for allfiles in viewfiles:
     file= os.path.join(path, allfiles)
     text=open(file, "r")
     for line in text:
     if re.match("DECRYPT_I", line):
         print line,


Vincent



More information about the Python-list mailing list