No KeyboardInterrupt error
This commit is contained in:
parent
2076d5f6a5
commit
671a528b7f
1 changed files with 12 additions and 7 deletions
19
redcode.py
Normal file → Executable file
19
redcode.py
Normal file → Executable file
|
@ -1,3 +1,4 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
from random import randint, choice
|
from random import randint, choice
|
||||||
from sys import stdout
|
from sys import stdout
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
@ -7,13 +8,17 @@ GREEN='\033[32m'
|
||||||
YELLOW='\033[33m'
|
YELLOW='\033[33m'
|
||||||
BLUE='\033[34m'
|
BLUE='\033[34m'
|
||||||
WHITE='\033[37m'
|
WHITE='\033[37m'
|
||||||
|
RESET='\033[0m'
|
||||||
|
|
||||||
colors = [ RED, GREEN, GREEN ]
|
colors = [ RED, GREEN, GREEN ]
|
||||||
|
|
||||||
while True:
|
try:
|
||||||
if randint(0,99) < 30:
|
while True:
|
||||||
stdout.write(choice(colors))
|
if randint(0,99) < 30:
|
||||||
stdout.write('%X' % randint(0,15))
|
stdout.write(choice(colors))
|
||||||
stdout.flush()
|
stdout.write('%X' % randint(0,15))
|
||||||
sleep(0.005)
|
stdout.flush()
|
||||||
|
sleep(0.005)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
stdout.write(RESET+"\n")
|
||||||
|
stdout.flush()
|
||||||
|
|
Loading…
Reference in a new issue