blob: 2869247fba93d4d4a9521bffa6ceb02998c04601 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import os
read_path = os.path.join(os.getcwd(), 'task5_data.txt')
write_path = os.path.join(os.getcwd(), 'task5_data_new.txt')
if not os.access(read_path, os.R_OK):
print('Файл "{}" не доступен для чтения'.format(read_path))
elif not os.access(write_path, os.W_OK):
print('Файл "{}" не доступен для записи'.format(write_path))
else:
with open(read_path) as f:
print(f.read())
with open('task5_data.txt', 'rb') as input_byte, open(write_path, 'wb') as out:
char = input_byte.read(1)
while char:
number = int(char.hex(), 16)
out.write(bytes([number ^ 2]))
char = input_byte.read(1)
|