Найти - Пользователи
Полная версия: Режим доступа к файлу
Начало » Python для новичков » Режим доступа к файлу
1 2
Shaman
py.user.next
Чего платформозависимо?
https://docs.python.org/2/library/functions.html#open
…and ‘a’ for appending (which on some Unix systems means that all writes append to the end of the file regardless of the current seek position)
Any questions?
py.user.next
Shaman
https://docs.python.org/2/library/functions.html#open
Shaman
which on some Unix systems
Это далеко не some, а практически на всех линуксах происходит.
Можешь проверить:
#!/usr/bin/env python3
 
with open('file.txt', 'a+b') as fout:
    fout.write(b'a1')
    fout.seek(0)
    fout.write(b'a2')
    fout.seek(0)
    fout.write(b'a3')
попробуй найти систему, где это запишется в начало.
JOHN_16
py.user.next
Там же про UNIX написано, а под BSD семейство , Solaris или тп тоже будет работать также? а Другие UNIX подобные системы? в общем есть шанс, что найдется и/или было подобное.
py.user.next
У меня под FreeBSD нет питона (надо ставить всё заново), но думаю, там то же самое с append'ом происходит.

Линуксовый системный вызов:
man 2 open
       O_APPEND
The file is opened in append mode. Before each write(2), the
file offset is positioned at the end of the file, as if with
lseek(2). O_APPEND may lead to corrupted files on NFS file sys‐
tems if more than one process appends data to a file at once.
This is because NFS does not support appending to a file, so the
client kernel has to simulate it, which can't be done without a
race condition.
...

CONFORMING TO
SVr4, 4.3BSD, POSIX.1-2001.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB