added rainbow.py
This commit is contained in:
parent
f56f3b9193
commit
315be48d01
26
rainbow.py
Normal file
26
rainbow.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
#! /usr/bin/env python3
|
||||
# coding=utf-8
|
||||
|
||||
import sys, time
|
||||
#timeStart = time.time()
|
||||
rainbow = "rrooyyYYGGggccCCBBbbmmMM"
|
||||
colorCode = {'r':5, 'o':4, 'y':7, 'Y':8, 'g':3, 'G':9, 'c':10, 'C':11, 'b':2, 'B':12, 'm':6, 'M':13, 0:1, 1:14, 2:15, 'w':0}
|
||||
|
||||
with open(sys.argv[1], 'r+', encoding="utf-8") as file:
|
||||
lines = file.readlines()
|
||||
|
||||
rainbowified = ""
|
||||
start = 0
|
||||
for line in lines:
|
||||
n = (start % len(rainbow))
|
||||
for char in line:
|
||||
rainbowified = rainbowified + '\x03' + str(colorCode[rainbow[(n % len(rainbow))]]) + char
|
||||
n = n + 1
|
||||
start = start + 1
|
||||
|
||||
print(rainbowified)
|
||||
|
||||
#with open('./test', 'w+') as file:
|
||||
# file.write(rainbowified)
|
||||
#timeEnd = time.time()
|
||||
#print(timeEnd - timeStart)
|
Loading…
Reference in New Issue
Block a user