Pythonで羽根をクルクル回す
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[今さらPython]]
Rubyの[[コンソールで羽根をクルクル回す]]のPython版。時計...
* code [#se5cdf2a]
#!/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 = ""
try:
while 1:
tx = datetime.datetime.now().strftime("%Y/%m/%d %...
if(tx != ttx):
ttx = tx
print("\r",flush=True,end="")
print(tx+" "+h.next(),flush=True,end="")
time.sleep(0.1)
except KeyboardInterrupt:
print("\nBye!")
exit
* 動作 [#v894f76f]
2023/07/10 13:10:43 -
なお、CTRL-Cすると「Bye!」と出して終わります。
終了行:
[[今さらPython]]
Rubyの[[コンソールで羽根をクルクル回す]]のPython版。時計...
* code [#se5cdf2a]
#!/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 = ""
try:
while 1:
tx = datetime.datetime.now().strftime("%Y/%m/%d %...
if(tx != ttx):
ttx = tx
print("\r",flush=True,end="")
print(tx+" "+h.next(),flush=True,end="")
time.sleep(0.1)
except KeyboardInterrupt:
print("\nBye!")
exit
* 動作 [#v894f76f]
2023/07/10 13:10:43 -
なお、CTRL-Cすると「Bye!」と出して終わります。
ページ名: