Simple Unicode String Example : Unicode : File PYTHON TUTORIALS


PYTHON TUTORIALS » File » Unicode »

 

Simple Unicode String Example


#!/usr/bin/env python

CODEC = 'utf-8'
FILE = 'unicode.txt'

hello_out = u"Hello worldn"
bytes_out = hello_out.encode(CODEC)
f = open(FILE, "w")
f.write(bytes_out)
f.close()

f = open(FILE, "r")
bytes_in = f.read()
f.close()
hello_in = bytes_in.decode(CODEC)
print hello_in,



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo File
» Unicode