file = open('unicode.txt', 'wb')
for i in range(10):
file.write(str(unichr(i) ))
What i would like to do is to print all of the Unicode values to a text file
file = open('unicode.txt', 'wb')
for i in range(10):
file.write(str(unichr(i) ))
What i would like to do is to print all of the Unicode values to a text file
You shouldn't need the str()
call around unichr(i)
. Python unicode
objects are printable.
This:
file = open('unicode.txt', 'wb')
for i in range(10):
file.write(unichr(i))
Seems to work for me, it prints 0x0000, 0x0001, 0x0002, etc. to the text file.
somefile = codecs.open('unicode.txt', 'wb', someencoding)
for i in range(10):
somefile.write(unichr(i))