blob: 5a942dd6aa2e4439196849f6718a95524b6dc51e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
import os
write_path = os.path.join(os.getcwd(), 'task2_data_1.txt')
read_path = os.path.join(os.getcwd(), 'task2_data_2.txt')
if not os.access(write_path, os.F_OK):
print('Файла "{}" не существует'.format(write_path))
elif not os.access(read_path, os.F_OK):
print('Файла "{}" не существует'.format(read_path))
elif not os.access(write_path, os.W_OK):
print('Файл "{}" не доступен для записи'.format(write_path))
elif not os.access(read_path, os.R_OK):
print('Файл "{}" не доступен для чтения'.format(read_path))
else:
with open(write_path, 'a') as first, open(read_path) as second:
first.write('\n\n\n')
data = second.read(1024)
first.write(data)
while data:
data = second.read(1024)
first.write(data)
os.rename('task2_data_1.txt', 'task2_data_all.txt')
os.remove('task2_data_2.txt')
|