posix
— 最常见的 POSIX 系统调用
¶
This module provides access to operating system functionality that is standardized by the C Standard and the POSIX standard (a thinly disguised Unix interface).
可用性 :Unix。
Do not import this module directly.
Instead, import the module
os
, which provides a
portable
version of this interface. On Unix, the
os
module provides a superset of the
posix
interface. On non-Unix operating systems the
posix
module is not available, but a subset is always available through the
os
interface. Once
os
is imported, there is
no
performance penalty in using it instead of
posix
. In addition,
os
provides some additional functionality, such as automatically calling
putenv()
when an entry in
os.environ
改变。
Errors are reported as exceptions; the usual exceptions are given for type errors, while errors reported by the system calls raise
OSError
.
大文件支持 ¶
Several operating systems (including AIX and Solaris) provide support for files that are larger than 2 GiB from a C programming model where int and long are 32-bit values. This is typically accomplished by defining the relevant size and offset types as 64-bit values. Such files are sometimes referred to as large files .
Large file support is enabled in Python when the size of an
off_t
is larger than a
long
和
long
long
is at least as large as an
off_t
. It may be necessary to configure and compile Python with certain compiler flags to enable this mode. For example, with Solaris 2.6 and 2.7 you need to do something like:
CFLAGS="`getconf LFS_CFLAGS`" OPT="-g -O2 $CFLAGS" \ ./configure