1import png
2s = ['110010010011',
3 '101011010100',
4 '110010110101',
5 '100010010011']
6s = [[int(c) for c in row] for row in s]
7
8w = png.Writer(len(s[0]), len(s), greyscale=True, bitdepth=1)
9f = open('png.png', 'wb')
10w.write(f, s)
11f.close()
12
13# https://pypng.readthedocs.io/en/latest/ex.html