Skip to content

Instantly share code, notes, and snippets.

@KatagiriSo
Created October 6, 2020 07:11
Show Gist options
  • Save KatagiriSo/273c1fac43ea728d51f741f868ce2f28 to your computer and use it in GitHub Desktop.
Save KatagiriSo/273c1fac43ea728d51f741f868ce2f28 to your computer and use it in GitHub Desktop.
ファイル内を一行づつ検索して表示
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