Здесь можно посмотреть распечатки dir() help() модуля os, os.sys, os.system, os.path ... Библиотека разветвленная, а времени на нее никогда не хватает. Так что просматривать этот пост надо бы при каждом удобном сучае.
In []:
[15.1. os — Miscellaneous operating system interfaces](https://docs.python.org/2/library/os.html#os.pathsep)
[10.1. os.path — Common pathname manipulations](https://docs.python.org/2/library/os.path.html#module-os.path)
In [1]:
import os
In [2]:
dir(os)
Out[2]:
['F_OK', 'O_APPEND', 'O_BINARY', 'O_CREAT', 'O_EXCL', 'O_NOINHERIT', 'O_RANDOM', 'O_RDONLY', 'O_RDWR', 'O_SEQUENTIAL', 'O_SHORT_LIVED', 'O_TEMPORARY', 'O_TEXT', 'O_TRUNC', 'O_WRONLY', 'P_DETACH', 'P_NOWAIT', 'P_NOWAITO', 'P_OVERLAY', 'P_WAIT', 'R_OK', 'SEEK_CUR', 'SEEK_END', 'SEEK_SET', 'TMP_MAX', 'UserDict', 'W_OK', 'X_OK', '_Environ', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_copy_reg', '_execvpe', '_exists', '_exit', '_get_exports_list', '_make_stat_result', '_make_statvfs_result', '_pickle_stat_result', '_pickle_statvfs_result', 'abort', 'access', 'altsep', 'chdir', 'chmod', 'close', 'closerange', 'curdir', 'defpath', 'devnull', 'dup', 'dup2', 'environ', 'errno', 'error', 'execl', 'execle', 'execlp', 'execlpe', 'execv', 'execve', 'execvp', 'execvpe', 'extsep', 'fdopen', 'fstat', 'fsync', 'getcwd', 'getcwdu', 'getenv', 'getpid', 'isatty', 'kill', 'linesep', 'listdir', 'lseek', 'lstat', 'makedirs', 'mkdir', 'name', 'open', 'pardir', 'path', 'pathsep', 'pipe', 'popen', 'popen2', 'popen3', 'popen4', 'putenv', 'read', 'remove', 'removedirs', 'rename', 'renames', 'rmdir', 'sep', 'spawnl', 'spawnle', 'spawnv', 'spawnve', 'startfile', 'stat', 'stat_float_times', 'stat_result', 'statvfs_result', 'strerror', 'sys', 'system', 'tempnam', 'times', 'tmpfile', 'tmpnam', 'umask', 'unlink', 'unsetenv', 'urandom', 'utime', 'waitpid', 'walk', 'write']
In [3]:
dir(os.sys)
Out[3]:
['__displayhook__', '__doc__', '__excepthook__', '__name__', '__package__', '__stderr__', '__stdin__', '__stdout__', '_clear_type_cache', '_current_frames', '_getframe', '_mercurial', 'api_version', 'argv', 'builtin_module_names', 'byteorder', 'call_tracing', 'callstats', 'copyright', 'displayhook', 'dllhandle', 'dont_write_bytecode', 'exc_clear', 'exc_info', 'exc_type', 'excepthook', 'exec_prefix', 'executable', 'exit', 'exitfunc', 'flags', 'float_info', 'float_repr_style', 'getcheckinterval', 'getdefaultencoding', 'getfilesystemencoding', 'getprofile', 'getrecursionlimit', 'getrefcount', 'getsizeof', 'gettrace', 'getwindowsversion', 'hexversion', 'long_info', 'maxint', 'maxsize', 'maxunicode', 'meta_path', 'modules', 'path', 'path_hooks', 'path_importer_cache', 'platform', 'prefix', 'ps1', 'ps2', 'ps3', 'py3kwarning', 'setcheckinterval', 'setprofile', 'setrecursionlimit', 'settrace', 'stderr', 'stdin', 'stdout', 'subversion', 'version', 'version_info', 'warnoptions', 'winver']
In [4]:
dir(os.system)
Out[4]:
['__call__', '__class__', '__cmp__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__self__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']
In [5]:
dir(os.SEEK_SET)
Out[5]:
['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__', '__delattr__', '__div__', '__divmod__', '__doc__', '__float__', '__floordiv__', '__format__', '__getattribute__', '__getnewargs__', '__hash__', '__hex__', '__index__', '__init__', '__int__', '__invert__', '__long__', '__lshift__', '__mod__', '__mul__', '__neg__', '__new__', '__nonzero__', '__oct__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'bit_length', 'conjugate', 'denominator', 'imag', 'numerator', 'real']
In [6]:
dir(os.path)
Out[6]:
['__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_abspath_split', '_getfullpathname', 'abspath', 'altsep', 'basename', 'commonprefix', 'curdir', 'defpath', 'devnull', 'dirname', 'exists', 'expanduser', 'expandvars', 'extsep', 'genericpath', 'getatime', 'getctime', 'getmtime', 'getsize', 'isabs', 'isdir', 'isfile', 'islink', 'ismount', 'join', 'lexists', 'normcase', 'normpath', 'os', 'pardir', 'pathsep', 'realpath', 'relpath', 'sep', 'split', 'splitdrive', 'splitext', 'splitunc', 'stat', 'supports_unicode_filenames', 'sys', 'walk', 'warnings']
In [7]:
help(os.path)
Help on module ntpath: NAME ntpath - Common pathname manipulations, WindowsNT/95 version. FILE c:\users\kiss\anaconda\lib\ntpath.py DESCRIPTION Instead of importing this module directly, import os and refer to this module as os.path. FUNCTIONS abspath(path) Return the absolute version of a path. basename(p) Returns the final component of a pathname commonprefix(m) Given a list of pathnames, returns the longest common leading component dirname(p) Returns the directory component of a pathname exists(path) Test whether a path exists. Returns False for broken symbolic links expanduser(path) Expand ~ and ~user constructs. If user or $HOME is unknown, do nothing. expandvars(path) Expand shell variables of the forms $var, ${var} and %var%. Unknown variables are left unchanged. getatime(filename) Return the last access time of a file, reported by os.stat(). getctime(filename) Return the metadata change time of a file, reported by os.stat(). getmtime(filename) Return the last modification time of a file, reported by os.stat(). getsize(filename) Return the size of a file, reported by os.stat(). isabs(s) Test whether a path is absolute isdir = _isdir(...) Return true if the pathname refers to an existing directory. isfile(path) Test whether a path is a regular file islink(path) Test for symbolic link. On WindowsNT/95 and OS/2 always returns false ismount(path) Test whether a path is a mount point (defined as root of drive) join(a, *p) Join two or more pathname components, inserting "\" as needed. If any component is an absolute path, all previous path components will be discarded. lexists = exists(path) Test whether a path exists. Returns False for broken symbolic links normcase(s) Normalize case of pathname. Makes all characters lowercase and all slashes into backslashes. normpath(path) Normalize path, eliminating double slashes, etc. realpath = abspath(path) Return the absolute version of a path. relpath(path, start='.') Return a relative version of a path split(p) Split a pathname. Return tuple (head, tail) where tail is everything after the final slash. Either part may be empty. splitdrive(p) Split a pathname into drive and path specifiers. Returns a 2-tuple "(drive,path)"; either part may be empty splitext(p) Split the extension from a pathname. Extension is everything from the last dot to the end, ignoring leading dots. Returns "(root, ext)"; ext may be empty. splitunc(p) Split a pathname into UNC mount point and relative path specifiers. Return a 2-tuple (unc, rest); either part may be empty. If unc is not empty, it has the form '//host/mount' (or similar using backslashes). unc+rest is always the input path. Paths containing drive letters never have an UNC part. walk(top, func, arg) Directory tree walk with callback function. For each directory in the directory tree rooted at top (including top itself, but excluding '.' and '..'), call func(arg, dirname, fnames). dirname is the name of the directory, and fnames a list of the names of the files and subdirectories in dirname (excluding '.' and '..'). func may modify the fnames list in-place (e.g. via del or slice assignment), and walk will only recurse into the subdirectories whose names remain in fnames; this can be used to implement a filter, or to impose a specific order of visiting. No semantics are defined for, or required of, arg, beyond that arg is always passed to func. It can be used, e.g., to pass a filename pattern, or a mutable object designed to accumulate statistics. Passing None for arg is common. DATA __all__ = ['normcase', 'isabs', 'join', 'splitdrive', 'split', 'splite... altsep = '/' curdir = '.' defpath = r'.;C:\bin' devnull = 'nul' extsep = '.' pardir = '..' pathsep = ';' sep = r'\' supports_unicode_filenames = True
Посты чуть ниже также могут вас заинтересовать
Комментариев нет:
Отправить комментарий