@charset "UTF-8";
filename = r'C:\Users\Python\Python35-32\lessons\charper_7\exp_1_read_text_from_file\charper_7\test.txt'
with open( filename, "r", encoding = 'utf-8') as text_file:
print(text_file.read(2))
from json import loads
import requests
w = 'кот'
d = requests.get('https://ru.wiktionary.org/w/api.php?action=query&titles=%s&prop=revisions&rvprop=content&format=json' % w)
print(loads(d.text))
import csv
with open('some.csv', newline='', encoding='utf-8') as f:
reader = csv.reader(f)
for row in reader:
print(row)
print(urllib.request.urlopen("http://ex.ua").read().decode('utf-8'))
import requests
requests.get('http://ex.ua').text
In [1]: s = "\u041f\u0440\u043e\u0441\u043c\u043e\u0442"
In [2]: print(str(s))
Просмот
в кодировке Windows 1251
cat str_*
stringstringstringстрокастрокастрока
file str_ru_text_1.txt
str_ru_text_1.txt: UTF-8 Unicode text, with no line terminators
file str_ru_text_2.txt
str_ru_text_2.txt: UTF-8 Unicode text, with no line terminators
file str_ru_bytes.txt
str_ru_bytes.txt: UTF-8 Unicode text, with no line terminators
file str_en_text_1.txt
str_en_text_1.txt: ASCII text, with no line terminators
file str_en_text_2.txt
str_en_text_2.txt: ASCII text, with no line terminators
file str_en_bytes.txt
str_en_bytes.txt: ASCII text, with no line terminators