python 2.7 - How to get a row from a file that starts with multiple prefixes -
i'm trying rows starts 's1', 's2'. below code.
import os f = open("test.csv","r") lines = f.readlines() f.close() f = open("test.csv","w") line in lines: if (line.startswith("s1") || line.startswith("s2")) f.write(line) f.close()
when run script i'm getting syntax error near '||'. looked link , made changes accordingly - how check if string starts 1 of several prefixes?
please let me know if i'm doing wrong. fyi, i'm using python 2.7.
thanks!
Comments
Post a Comment