如果没有 numpy 模块,我怎么能做到这一点?它绘制了一个 256x256 的白色正方形
rows = [[255 for element in xrange(4) for number_of_pixles in xrange(256)] for number_of_rows in xrange(256)]
import numpy # Using numpy is much faster
rows = numpy.zeros((256, 256 * 4), dtype = 'int')
rows[:] = 255
png_writer = png.Writer(width = 256, height = 256, alpha = 'RGBA')
png_writer.write(open('white_panel.png', 'wb'), rows)