Created
October 6, 2020 07:11
-
-
Save KatagiriSo/273c1fac43ea728d51f741f868ce2f28 to your computer and use it in GitHub Desktop.
ファイル内を一行づつ検索して表示
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
# 該当言語 | |
searchWord = "hoge" | |
# ファイル読み込み | |
text = open(sys.argv[1], "r") | |
# 一行づつ読み出し | |
for line in text: | |
# 該当単語があるなら書き出し | |
if searchWord in line: | |
print(line) | |
# 閉じる | |
text.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment