У меня такая же проблема на Cygwin/Windows и в Debian с помощью ssh. Если открыть терминал и копировать/вставить весь этот код сразу:Python3: копирование/вставка работает только в двух шагах
f = open('dst.txt', 'w', encoding='utf-8')
f.write('\xc4\xc4\xc4')
f.close
text = open('dst.txt', encoding='utf-8').read()
text
len(text)
я получаю:
Python 3.6.0a0 (default, Jul 7 2015, 23:55:18)
[GCC 4.7.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> f = open('dst.txt', 'w', encoding='utf-8')
>>> f.write('\xc4\xc4\xc4')
3
>>> f.close
<built-in method close of _io.TextIOWrapper object at 0x7f65c03b8b40>
>>> text = open('dst.txt', encoding='utf-8').read()
>>> text
''
>>> len(text)
0
>>>
Теперь, если я делаю это в два шага:
f = open('dst.txt', 'w', encoding='utf-8')
f.write('\xc4\xc4\xc4')
f.close
После этого:
text = open('dst.txt', encoding='utf-8').read()
text
len(text)
Я получаю:
[email protected]:~$ python3
Python 3.6.0a0 (default, Jul 7 2015, 23:55:18)
[GCC 4.7.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> f = open('dst.txt', 'w', encoding='utf-8')
>>> f.write('\xc4\xc4\xc4')
3
>>> f.close
<built-in method close of _io.TextIOWrapper object at 0x7fb1a9353b40>
>>>
[email protected]:~$ python3
Python 3.6.0a0 (default, Jul 7 2015, 23:55:18)
[GCC 4.7.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> text = open('dst.txt', encoding='utf-8').read()
>>> text
'ÄÄÄ'
>>> len(text)
3
>>>
Что здесь происходит?