MyTetra Share
Делитесь знаниями!
Кодировка: сравнение 2 и 3 версии Python
Время создания: 31.08.2017 21:01
Текстовые метки: knowledge
Раздел: Python - Кодировка - Анализ кодировки
Запись: xintrea/mytetra_db_mcold/master/base/1503305610t3a30ujtnd/text.html на raw.githubusercontent.com
#coding: utf-8

with open('1.txt') as fh:
s = fh.read()
print(type(s))
print(s)

parser_result =
u'баба-яга'

print(parser_result + s)



Python 2:


Traceback (most recent call last):

File "C:/Users/holodnuk/Desktop/ChaineR-master/test.py", line 10, in <module>

print(parser_result + s)

UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)

<type 'str'>

кощей



Python 3: все строки юникод


<class 'str'>

кощей

баба-ягакощей

 
MyTetra Share v.0.59
Яндекс индекс цитирования