import codecs
p = '\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043a\u043b'
print(p)
with codecs.open('tets.txt', 'w', 'utf-16') as stream:
    stream.write(p + '\n')
How to write Russian characters in file?