Superimpose.py: Difference between revisions
No edit summary |
No edit summary |
||
Line 34: | Line 34: | ||
[[Category: Cookbook]] | [[Category: Cookbook]] | ||
[[Category: ASCII Art]] |
Latest revision as of 19:37, 15 December 2018
Description
Superimposes ASCII art
Usage
figlet hello > hello.txt figlet world > world.txt python superimpose hello.txt world.txt
produces...
_ _ _ _ _ __|__ _____| _ __| | __| | \ \_/\ / / _ \||'__|\|/ _` | |\|V| V /_(_)||||(_| | (_| | |_\_/\_/_\___/|_|__|_|\__,_|
Code
import itertools
import sys
for x, y in zip(open(sys.argv[1]), open(sys.argv[2])):
for xc, yc in itertools.izip_longest(x.rstrip('\r\n'), y.rstrip('\r\n'), fillvalue=' '):
if yc == ' ':
sys.stdout.write(xc);
else:
sys.stdout.write(yc);
sys.stdout.write('\n')
Source: Alexandre Leray