-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex23.py
More file actions
24 lines (18 loc) · 672 Bytes
/
ex23.py
File metadata and controls
24 lines (18 loc) · 672 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#Łańcuchy znaków, bajty i kodowanie znaków
import sys
script, 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):
#usunięcie spacji
next_lang = line.strip()
#enkodowanie
raw_bytes = next_lang.encode(encoding, errors=errors)
#dekadowanie
cooked_string = raw_bytes.decode(encoding, errors=errors)
print(raw_bytes, "<====>", cooked_string)
languages = open("languages.txt", encoding="utf-8")
main(languages, encoding, error)