Em đang học python theo cuốn learn python 3 the hard way nhưng tới bài 23 thì run file nó không chạy mong mọi người giúp đỡ.
Em đã chỉnh codepage sang utf-8 nhưng nó vẫn không chạy, code:
import sys
script, input_encoding, error = sys.argv
def main(language_file, encoding, errors):
line = language_file.readline()
if line:
print_line(line, encoding, errors)
return main(language_file, encoding, errors)
def print_line(line, encoding, errors):
next_lang = line.strip()
raw_bytes = next_lang.encode(encoding, errors=errors)
cooked_string = raw_bytes.decode(encoding, errors=errors)
print(raw_bytes, "<===>", cooked_string)
languages = open("test.txt", encoding="utf-8")
main(languages, input_encoding, error)
Lỗi khi run file: