How To Copy Lines From Several Files Base On Conditions In Python?
I am coding a little python scrpit to grab lines from several files according to a config file. Config file looks like this: [BeginObjects] apple banana [EndObjects] [BeginFiles]
Solution 1:
The easiest way to check this is with if ... in ...
, like so:
if"[BeginObjects]"in line:
print"We found the string '[BringObjects]'"
Solution 2:
Tag=Falsefor line in infile:for item in itemObj:ifline.find("ObjectAlias" + item + "\n")!=-1:Tag=Trueif Tag:dummy+=lineifline.find("End")!=-1:Tag=False
You just need to change your if statement
Post a Comment for "How To Copy Lines From Several Files Base On Conditions In Python?"