str_ru = 'строка'
with open('8.txt', 'w', encoding="utf-8") as f:
f.write(str_ru)
with open('8.txt', 'r') as f:
print(f.read())
with open('1.txt', 'w', encoding="cp1251") as f:
f.write(str_ru)
with open('1.txt', 'r', encoding="cp1251") as f:
print(f.read())