A script that "outputs a line containing the specified character string from a text file".
In my case, Python scripts are often written when processing text files.
First, write this script as a template, and add processing later. \ # Therefore, this script can be written at the "hands move" level (^^;)
It comes in handy when you don't have the grep command or editor function!
# -*- coding: utf-8 -*-
ld = open("text file.txt")
lines = ld.readlines()
ld.close()
for line in lines:
if line.find("Search character") >= 0:
print(line[:-1])
Recommended Posts