I'm trying to make a text file that contains all 54607 printable characters, but each line should only be 80 characters long for readability.
utf_all = ' !"#$'...'
lines = '\n'.join(utf_all[i:i+80] for i in range(0, 54607, 80))
file = open('allchars.txt', 'w').write(lines)
That returns an error message
UnicodeEncodeError: 'charmap' codec can't encode characters in position 193-243: character maps to
<undefined>
If I try encoding the characters and writing in binary mode it ignores the newline \n and puts the entire string into one line and appends a newline to the end of the file.