Pythonでファイルの作成時刻や最終更新時刻を取得する方法

Pythonでファイルの作成時刻や最終更新時刻を取得するにはgetctimegetmtimeを使うと良いそうです。

使い方は次のような感じです。

作成時刻

>>> import os
>>> os.path.getctime('/path/to/file')
1542761883.7563891

最終更新時刻

>>> os.path.getmtime('/path/to/file')
1542761883.7563891

最終アクセス時刻

>>> os.path.getatime('/path/to/file')
1542761883.7563891

戻り値はepochからの経過秒数になっています。timeモジュールを使うと読み易い形に変換できます。

>>> import time
>>> time.strftime('%Y-%m-%d %I:%M:%S', time.localtime(1542761883.7563891))
'2018-11-21 09:58:03'

GitHub Freeでプライベートリポジトリが作成可能になりました

GitHubの無料プランでプライベートリポジトリの作成が可能になったそうです。

Unlimited free private repositories with GitHub Free and a unified business offering with GitHub Enterprise | The GitHub Blog
https://blog.github.com/changelog/2019-01-08-pricing-changes/

個人的にはNASにGitをインストールして使っていますが、その作業が煩わしかったり物理的に離れた場所にいる人と共同で開発をしている人にとっては選択肢が増えたのではないかと思います。

FreeプランとProプランの比較

FreeプランProプラン
Publicリポジトリ
Privateリポジトリ
GitHub PagesとWiki
(Publicリポジトリのみ)
価格無料7ドル/月

リンク

Pricing · Plans for every developer · GitHub
https://github.com/pricing

Unityでゲームを終了させるコード

Unityのゲームを終了させたい場合、右上の×ボタンとかAlt+F4で終了させることもできますが、もう少しスマートにしたい場合はApplication.Quitを使うとよいそうです。

使い方

void Update()
{
  if (Input.GetKey(KeyCode.Escape)) {
    Application.Quit();
  }
}

ちなみに上のコードは、UnityのEditor上でDebugしているときには使えません。Editor上でDebugを終了させたい場合はUnityEditor.EditorApplication.isPlayingを使って次のような感じにすることができるそうです。

void Update()
{
  if (Input.GetKey(KeyCode.Escape)) {
#if UNITY_EDITOR
    UnityEditor.EditorApplication.isPlaying = false;
#else
    Application.Quit();
#endif
  }
}

リンク

Unity – Scripting API: Application.Quit
https://docs.unity3d.com/ScriptReference/Application.Quit.html

Application.Quit not working?! – Unity Answers
https://answers.unity.com/questions/899037/applicationquit-not-working-1.html