#author("2023-05-22T16:52:23+09:00","default:yakumo_murakami","yakumo_murakami") #author("2023-05-22T16:55:31+09:00","default:yakumo_murakami","yakumo_murakami") [[今さらPython]] シェルでやってる羽根回しをPythonでやってみたわ。 UNIXおなじみの[[コンソールで羽根をクルクル回す]]やつをPythonでやってみたわ。 * コード [#v9ec1c95] #!/usr/bin/env python import datetime import time class Hane(): def __init__(self): self.s = ["/","-","\\","|"] self.si = 0 def next(self): self.si = self.si + 1 if(self.si > 3): self.si = 0 return(str(self.s[self.si])) h = Hane() ttx = "" while 1: tx = datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S") if(tx != ttx): ttx = tx print("\r",flush=True,end="") print(tx+" "+h.next(),flush=True,end="") time.sleep(0.1) * 実行 [#y8f4c76f] 2023/05/21 16:51:07 /