lst = [1,2,3,4,5] with open('out', 'wb') as f: f.write(lst)