前提
問い合わせが一番多いIPアドレスを見つけるプログラムの作成しています.
以下のコードは問い合わせてきたipアドレスとその回数を出力するプログラムです.
コード
csvファイルの中身 カンマ区切りで3行目がipアドレス 1673020100.777410000,111.211.13.108,255.0.0.255 ・ ・ ・
python
1ipcount = {} 2 3with open("./xxxxxxx.csv") as f: 4 for line in f: 5 srcip = line.split(",")[1] 6 if srcip not in ipcount: 7 ipcount[srcip] = 0 8 ipcount[srcip] += 1 9for srcip in ipcount: 10 print(f"{srcip} {ipcount[srcip]}")
表示結果
195.178.120.130 3 27.15.155.87 1 222.162.139.123 1 175.212.32.107 6 220.163.214.90 1 113.0.177.206 1 94.182.240.21 1 188.56.195.27 1
質問
上のコードのprint(f"{srcip} {ipcount[srcip]}")
のf
ってどういう意味ですか?
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2023/01/19 07:14