通用操作系统服务¶
本章中描述的各模块提供了在(几乎)所有的操作系统上可用的操作系统特性的接口,例如文件和时钟。这些接口通常以 Unix 或 C 接口为参考对象,不过在大多数其他系统上也可用。这里有一个概述:
os
--- 多种操作系统接口error
name
- 文件名,命令行参数,以及环境变量。
- Python UTF-8 模式
- 进程参数
ctermid()
environ
environb
fsencode()
fsdecode()
fspath()
PathLike
getenv()
getenvb()
get_exec_path()
getegid()
geteuid()
getgid()
getgrouplist()
getgroups()
getlogin()
getpgid()
getpgrp()
getpid()
getppid()
getpriority()
PRIO_PROCESS
PRIO_PGRP
PRIO_USER
PRIO_DARWIN_THREAD
PRIO_DARWIN_PROCESS
PRIO_DARWIN_BG
PRIO_DARWIN_NONUI
getresuid()
getresgid()
getuid()
initgroups()
putenv()
setegid()
seteuid()
setgid()
setgroups()
setns()
setpgrp()
setpgid()
setpriority()
setregid()
setresgid()
setresuid()
setreuid()
getsid()
setsid()
setuid()
strerror()
supports_bytes_environ
umask()
uname()
unsetenv()
unshare()
CLONE_FILES
CLONE_FS
CLONE_NEWCGROUP
CLONE_NEWIPC
CLONE_NEWNET
CLONE_NEWNS
CLONE_NEWPID
CLONE_NEWTIME
CLONE_NEWUSER
CLONE_NEWUTS
CLONE_SIGHAND
CLONE_SYSVSEM
CLONE_THREAD
CLONE_VM
- 创建文件对象
- 文件描述符操作
close()
closerange()
copy_file_range()
device_encoding()
dup()
dup2()
fchmod()
fchown()
fdatasync()
fpathconf()
fstat()
fstatvfs()
fsync()
ftruncate()
get_blocking()
grantpt()
isatty()
lockf()
F_LOCK
F_TLOCK
F_ULOCK
F_TEST
login_tty()
lseek()
SEEK_SET
SEEK_CUR
SEEK_END
SEEK_HOLE
SEEK_DATA
open()
O_RDONLY
O_WRONLY
O_RDWR
O_APPEND
O_CREAT
O_EXCL
O_TRUNC
O_DSYNC
O_RSYNC
O_SYNC
O_NDELAY
O_NONBLOCK
O_NOCTTY
O_CLOEXEC
O_BINARY
O_NOINHERIT
O_SHORT_LIVED
O_TEMPORARY
O_RANDOM
O_SEQUENTIAL
O_TEXT
O_EVTONLY
O_FSYNC
O_SYMLINK
O_NOFOLLOW_ANY
O_ASYNC
O_DIRECT
O_DIRECTORY
O_NOFOLLOW
O_NOATIME
O_PATH
O_TMPFILE
O_SHLOCK
O_EXLOCK
openpty()
pipe()
pipe2()
posix_fallocate()
posix_fadvise()
POSIX_FADV_NORMAL
POSIX_FADV_SEQUENTIAL
POSIX_FADV_RANDOM
POSIX_FADV_NOREUSE
POSIX_FADV_WILLNEED
POSIX_FADV_DONTNEED
pread()
posix_openpt()
preadv()
RWF_NOWAIT
RWF_HIPRI
ptsname()
pwrite()
pwritev()
RWF_DSYNC
RWF_SYNC
RWF_APPEND
read()
sendfile()
SF_NODISKIO
SF_MNOWAIT
SF_SYNC
SF_NOCACHE
set_blocking()
splice()
SPLICE_F_MOVE
SPLICE_F_NONBLOCK
SPLICE_F_MORE
readv()
tcgetpgrp()
tcsetpgrp()
ttyname()
unlockpt()
write()
writev()
- 查询终端的尺寸
- 文件描述符的继承
- 文件和目录
access()
F_OK
R_OK
W_OK
X_OK
chdir()
chflags()
chmod()
chown()
chroot()
fchdir()
getcwd()
getcwdb()
lchflags()
lchmod()
lchown()
link()
listdir()
listdrives()
listmounts()
listvolumes()
lstat()
mkdir()
makedirs()
mkfifo()
mknod()
major()
minor()
makedev()
pathconf()
pathconf_names
readlink()
remove()
removedirs()
rename()
renames()
replace()
rmdir()
scandir()
DirEntry
stat()
stat_result
statvfs()
supports_dir_fd
supports_effective_ids
supports_fd
supports_follow_symlinks
symlink()
sync()
truncate()
unlink()
utime()
walk()
fwalk()
memfd_create()
MFD_CLOEXEC
MFD_ALLOW_SEALING
MFD_HUGETLB
MFD_HUGE_SHIFT
MFD_HUGE_MASK
MFD_HUGE_64KB
MFD_HUGE_512KB
MFD_HUGE_1MB
MFD_HUGE_2MB
MFD_HUGE_8MB
MFD_HUGE_16MB
MFD_HUGE_32MB
MFD_HUGE_256MB
MFD_HUGE_512MB
MFD_HUGE_1GB
MFD_HUGE_2GB
MFD_HUGE_16GB
eventfd()
eventfd_read()
eventfd_write()
EFD_CLOEXEC
EFD_NONBLOCK
EFD_SEMAPHORE
- 计时器文件描述符
- Linux 扩展属性
- 进程管理
abort()
add_dll_directory()
execl()
execle()
execlp()
execlpe()
execv()
execve()
execvp()
execvpe()
_exit()
EX_OK
EX_USAGE
EX_DATAERR
EX_NOINPUT
EX_NOUSER
EX_NOHOST
EX_UNAVAILABLE
EX_SOFTWARE
EX_OSERR
EX_OSFILE
EX_CANTCREAT
EX_IOERR
EX_TEMPFAIL
EX_PROTOCOL
EX_NOPERM
EX_CONFIG
EX_NOTFOUND
fork()
forkpty()
kill()
killpg()
nice()
pidfd_open()
plock()
popen()
posix_spawn()
posix_spawnp()
register_at_fork()
spawnl()
spawnle()
spawnlp()
spawnlpe()
spawnv()
spawnve()
spawnvp()
spawnvpe()
P_NOWAIT
P_NOWAITO
P_WAIT
P_DETACH
P_OVERLAY
startfile()
system()
times()
wait()
waitid()
waitpid()
wait3()
wait4()
P_PID
P_PGID
P_ALL
P_PIDFD
WCONTINUED
WEXITED
WSTOPPED
WUNTRACED
WNOHANG
WNOWAIT
CLD_EXITED
CLD_KILLED
CLD_DUMPED
CLD_TRAPPED
CLD_STOPPED
CLD_CONTINUED
waitstatus_to_exitcode()
WCOREDUMP()
WIFCONTINUED()
WIFSTOPPED()
WIFSIGNALED()
WIFEXITED()
WEXITSTATUS()
WSTOPSIG()
WTERMSIG()
- 调度器接口
SCHED_OTHER
SCHED_BATCH
SCHED_IDLE
SCHED_SPORADIC
SCHED_FIFO
SCHED_RR
SCHED_RESET_ON_FORK
sched_param
sched_get_priority_min()
sched_get_priority_max()
sched_setscheduler()
sched_getscheduler()
sched_setparam()
sched_getparam()
sched_rr_get_interval()
sched_yield()
sched_setaffinity()
sched_getaffinity()
- 其他系统信息
- 随机数
io
--- 处理流的核心工具time
--- 时间的访问和转换- 函数
asctime()
pthread_getcpuclockid()
clock_getres()
clock_gettime()
clock_gettime_ns()
clock_settime()
clock_settime_ns()
ctime()
get_clock_info()
gmtime()
localtime()
mktime()
monotonic()
monotonic_ns()
perf_counter()
perf_counter_ns()
process_time()
process_time_ns()
sleep()
strftime()
strptime()
struct_time
time()
time_ns()
thread_time()
thread_time_ns()
tzset()
- Clock ID 常量
- 时区常量
- 函数
argparse
--- 用于命令行选项、参数和子命令的解析器logging
--- Python 的日志记录工具logging.config
--- 日志记录配置logging.handlers
--- 日志处理器getpass
--- 可移植的密码输入curses
--- 字符单元显示的终端处理- 函数
error
baudrate()
beep()
can_change_color()
cbreak()
color_content()
color_pair()
curs_set()
def_prog_mode()
def_shell_mode()
delay_output()
doupdate()
echo()
endwin()
erasechar()
filter()
flash()
flushinp()
getmouse()
getsyx()
getwin()
has_colors()
has_extended_color_support()
has_ic()
has_il()
has_key()
halfdelay()
init_color()
init_pair()
initscr()
is_term_resized()
isendwin()
keyname()
killchar()
longname()
meta()
mouseinterval()
mousemask()
napms()
newpad()
newwin()
nl()
nocbreak()
noecho()
nonl()
noqiflush()
noraw()
pair_content()
pair_number()
putp()
qiflush()
raw()
reset_prog_mode()
reset_shell_mode()
resetty()
resize_term()
resizeterm()
savetty()
get_escdelay()
set_escdelay()
get_tabsize()
set_tabsize()
setsyx()
setupterm()
start_color()
termattrs()
termname()
tigetflag()
tigetnum()
tigetstr()
tparm()
typeahead()
unctrl()
ungetch()
update_lines_cols()
unget_wch()
ungetmouse()
use_env()
use_default_colors()
wrapper()
- Window 对象
addch()
addnstr()
addstr()
attroff()
attron()
attrset()
bkgd()
bkgdset()
border()
box()
chgat()
clear()
clearok()
clrtobot()
clrtoeol()
cursyncup()
delch()
deleteln()
derwin()
echochar()
enclose()
encoding
erase()
getbegyx()
getbkgd()
getch()
get_wch()
getkey()
getmaxyx()
getparyx()
getstr()
getyx()
hline()
idcok()
idlok()
immedok()
inch()
insch()
insdelln()
insertln()
insnstr()
insstr()
instr()
is_linetouched()
is_wintouched()
keypad()
leaveok()
move()
mvderwin()
mvwin()
nodelay()
notimeout()
noutrefresh()
overlay()
overwrite()
putwin()
redrawln()
redrawwin()
refresh()
resize()
scroll()
scrollok()
setscrreg()
standend()
standout()
subpad()
subwin()
syncdown()
syncok()
syncup()
timeout()
touchline()
touchwin()
untouchwin()
vline()
- 常量
ERR
OK
version
__version__
ncurses_version
COLORS
COLOR_PAIRS
COLS
LINES
A_ALTCHARSET
A_BLINK
A_BOLD
A_DIM
A_INVIS
A_ITALIC
A_NORMAL
A_PROTECT
A_REVERSE
A_STANDOUT
A_UNDERLINE
A_HORIZONTAL
A_LEFT
A_LOW
A_RIGHT
A_TOP
A_VERTICAL
A_ATTRIBUTES
A_CHARTEXT
A_COLOR
KEY_MIN
KEY_BREAK
KEY_DOWN
KEY_UP
KEY_LEFT
KEY_RIGHT
KEY_HOME
KEY_BACKSPACE
KEY_F0
KEY_Fn
KEY_DL
KEY_IL
KEY_DC
KEY_IC
KEY_EIC
KEY_CLEAR
KEY_EOS
KEY_EOL
KEY_SF
KEY_SR
KEY_NPAGE
KEY_PPAGE
KEY_STAB
KEY_CTAB
KEY_CATAB
KEY_ENTER
KEY_SRESET
KEY_RESET
KEY_PRINT
KEY_LL
KEY_A1
KEY_A3
KEY_B2
KEY_C1
KEY_C3
KEY_BTAB
KEY_BEG
KEY_CANCEL
KEY_CLOSE
KEY_COMMAND
KEY_COPY
KEY_CREATE
KEY_END
KEY_EXIT
KEY_FIND
KEY_HELP
KEY_MARK
KEY_MESSAGE
KEY_MOVE
KEY_NEXT
KEY_OPEN
KEY_OPTIONS
KEY_PREVIOUS
KEY_REDO
KEY_REFERENCE
KEY_REFRESH
KEY_REPLACE
KEY_RESTART
KEY_RESUME
KEY_SAVE
KEY_SBEG
KEY_SCANCEL
KEY_SCOMMAND
KEY_SCOPY
KEY_SCREATE
KEY_SDC
KEY_SDL
KEY_SELECT
KEY_SEND
KEY_SEOL
KEY_SEXIT
KEY_SFIND
KEY_SHELP
KEY_SHOME
KEY_SIC
KEY_SLEFT
KEY_SMESSAGE
KEY_SMOVE
KEY_SNEXT
KEY_SOPTIONS
KEY_SPREVIOUS
KEY_SPRINT
KEY_SREDO
KEY_SREPLACE
KEY_SRIGHT
KEY_SRSUME
KEY_SSAVE
KEY_SSUSPEND
KEY_SUNDO
KEY_SUSPEND
KEY_UNDO
KEY_MOUSE
KEY_RESIZE
KEY_MAX
ACS_BBSS
ACS_BLOCK
ACS_BOARD
ACS_BSBS
ACS_BSSB
ACS_BSSS
ACS_BTEE
ACS_BULLET
ACS_CKBOARD
ACS_DARROW
ACS_DEGREE
ACS_DIAMOND
ACS_GEQUAL
ACS_HLINE
ACS_LANTERN
ACS_LARROW
ACS_LEQUAL
ACS_LLCORNER
ACS_LRCORNER
ACS_LTEE
ACS_NEQUAL
ACS_PI
ACS_PLMINUS
ACS_PLUS
ACS_RARROW
ACS_RTEE
ACS_S1
ACS_S3
ACS_S7
ACS_S9
ACS_SBBS
ACS_SBSB
ACS_SBSS
ACS_SSBB
ACS_SSBS
ACS_SSSB
ACS_SSSS
ACS_STERLING
ACS_TTEE
ACS_UARROW
ACS_ULCORNER
ACS_URCORNER
ACS_VLINE
BUTTONn_PRESSED
BUTTONn_RELEASED
BUTTONn_CLICKED
BUTTONn_DOUBLE_CLICKED
BUTTONn_TRIPLE_CLICKED
BUTTON_SHIFT
BUTTON_CTRL
BUTTON_ALT
COLOR_BLACK
COLOR_BLUE
COLOR_CYAN
COLOR_GREEN
COLOR_MAGENTA
COLOR_RED
COLOR_WHITE
COLOR_YELLOW
- 函数
curses.textpad
--- 用于 curses 程序的文本输入控件curses.ascii
--- 用于 ASCII 字符的工具NUL
SOH
STX
ETX
EOT
ENQ
ACK
BEL
BS
TAB
HT
LF
NL
VT
FF
CR
SO
SI
DLE
DC1
DC2
DC3
DC4
NAK
SYN
ETB
CAN
EM
SUB
ESC
FS
GS
RS
US
SP
DEL
isalnum()
isalpha()
isascii()
isblank()
iscntrl()
isdigit()
isgraph()
islower()
isprint()
ispunct()
isspace()
isupper()
isxdigit()
isctrl()
ismeta()
ascii()
ctrl()
alt()
unctrl()
controlnames
curses.panel
--- 针对 curses 的面板栈扩展platform
--- 访问底层平台的标识数据errno
--- 标准 errno 系统符号errorcode
EPERM
ENOENT
ESRCH
EINTR
EIO
ENXIO
E2BIG
ENOEXEC
EBADF
ECHILD
EAGAIN
ENOMEM
EACCES
EFAULT
ENOTBLK
EBUSY
EEXIST
EXDEV
ENODEV
ENOTDIR
EISDIR
EINVAL
ENFILE
EMFILE
ENOTTY
ETXTBSY
EFBIG
ENOSPC
ESPIPE
EROFS
EMLINK
EPIPE
EDOM
ERANGE
EDEADLK
ENAMETOOLONG
ENOLCK
ENOSYS
ENOTEMPTY
ELOOP
EWOULDBLOCK
ENOMSG
EIDRM
ECHRNG
EL2NSYNC
EL3HLT
EL3RST
ELNRNG
EUNATCH
ENOCSI
EL2HLT
EBADE
EBADR
EXFULL
ENOANO
EBADRQC
EBADSLT
EDEADLOCK
EBFONT
ENOSTR
ENODATA
ETIME
ENOSR
ENONET
ENOPKG
EREMOTE
ENOLINK
EADV
ESRMNT
ECOMM
EPROTO
EMULTIHOP
EDOTDOT
EBADMSG
EOVERFLOW
ENOTUNIQ
EBADFD
EREMCHG
ELIBACC
ELIBBAD
ELIBSCN
ELIBMAX
ELIBEXEC
EILSEQ
ERESTART
ESTRPIPE
EUSERS
ENOTSOCK
EDESTADDRREQ
EMSGSIZE
EPROTOTYPE
ENOPROTOOPT
EPROTONOSUPPORT
ESOCKTNOSUPPORT
EOPNOTSUPP
ENOTSUP
EPFNOSUPPORT
EAFNOSUPPORT
EADDRINUSE
EADDRNOTAVAIL
ENETDOWN
ENETUNREACH
ENETRESET
ECONNABORTED
ECONNRESET
ENOBUFS
EISCONN
ENOTCONN
ESHUTDOWN
ETOOMANYREFS
ETIMEDOUT
ECONNREFUSED
EHOSTDOWN
EHOSTUNREACH
EALREADY
EINPROGRESS
ESTALE
EUCLEAN
ENOTNAM
ENAVAIL
EISNAM
EREMOTEIO
EDQUOT
EQFULL
ENOTCAPABLE
ECANCELED
EOWNERDEAD
ENOTRECOVERABLE
ctypes
--- Python 的外部函数库- ctypes 教程
- ctypes 参考手册
- 寻找动态链接库
- 加载动态链接库
- 外部函数
- 函数原型
- 工具函数
addressof()
alignment()
byref()
cast()
create_string_buffer()
create_unicode_buffer()
DllCanUnloadNow()
DllGetClassObject()
find_library()
find_msvcrt()
FormatError()
GetLastError()
get_errno()
get_last_error()
memmove()
memset()
POINTER()
pointer()
resize()
set_errno()
set_last_error()
sizeof()
string_at()
WinError()
wstring_at()
- 数据类型
- 基础数据类型
- 结构化数据类型
- 数组与指针