LoginSignup
1
0

More than 1 year has passed since last update.

好きなアイドルの曲に同じ言葉が何回出てくるか調べる

Posted at

はじめに

「=LOVE」というアイドルが好きです。

指原莉乃さんが作曲する歌詞が印象に残る曲ばかりなのですが、
特に好きな1曲(『桜が咲く音がした』)に同じ言葉(桜)が何回出てくるか調べました。

環境

Mac OS 10.15.7
Python 3.8.8

コード

test.py 
file = "test.txt" #ファイル名
with open(file) as fileobj: #ファイルオブジェクトを作る
    text = fileobj.read() #ファイルを読み込む
    t = str(text) # 文字列に変換
    print(t.count("桜")) #数を数えて表示

終わりに

3回でした!
意外と少なかった。

参考文献

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0