Created
March 22, 2018 02:42
-
-
Save devlights/e0cd652010d6d322d27f871fb95d6fc4 to your computer and use it in GitHub Desktop.
[python] コンソールに現在日時を表示し続けるスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime as dt | |
import time as tm | |
import sys | |
def go(): | |
while True: | |
d = dt.datetime.now() | |
now = d.strftime('%Y/%m/%d %H:%M:%S') | |
sys.stdout.write(f'\r{now}') | |
sys.stdout.flush() | |
tm.sleep(1) | |
if __name__ == '__main__': | |
go() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
たまに重宝してるプチスクリプト。
python2で動作させる場合は
の部分を
に変更する。