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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -