- Python 3.7.1
- 利用外部ライブラリ
- dateutil(
pip install python-dateutil
で入手する)
- dateutil(
同じディレクトリに存在するaccess.log ファイルを読み取り、24時間別にアクセスしたリモートホスト名とそのアクセス数を降順で出力する。
- open関数を用いて対象のファイルを読み取る。
- 読み取った情報から、アクセスしたリモートホスト名とアクセス時間を正規表現で抽出する。
- アクセス時間より、0から23時のアクセスに分類する。
- 各時間ごとにリモートホストあたりのアクセス数を算出する。
- 上記結果を出力する。