Output the line containing the specified string

http://qiita.com/qt-luigi/items/76f7955d68418f967efb I would do this.

for line in open("text file.txt"):
    if "Search character" in line:
        print line,

Recommended Posts

Output the line containing the specified string
Outputs a line containing the specified character string from a text file
[Python] Read the specified line in the file
Divide the string into the specified number of characters
How to delete the specified string with the sed command! !! !!
Output a character string with line breaks in PyYAML
Output unicode string list
[Python 2/3] Parse the format string
Filter the output of tracemalloc
Read the standard output of a subprocess line by line in Python
How to extract the desired character string from a line 4 commands