Windows下python命令行画图(4位彩色)
from ctypes import windll STD_OUTPUT_HANDLE = -11 # input -10, error -12stdout_handle = windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE)
def f(x,easy=True):
x = x*16 if easy else x
windll.kernel32.SetConsoleTextAttribute(stdout_handle, x)
def print_(l,px=''):
# l为一行的颜色列表, 取值0~15(现成的颜色就这么几种,自己看吧), 长度小于命令行宽度
length = len(l)
lines =
for x in reversed(l):
f(x)
print(lines.pop(),end='\r')
print()
import random
for x in range(34):
l =
print_(l)
f(0x07,False)
页:
[1]