1. 程式人生 > >進階第十二課 Python模塊之sys

進階第十二課 Python模塊之sys

read OS python模塊 leg gac pack uil file pos

sys是與Python解釋器交互的工具。

先看下dir(sys)

>>> import sys
>>> dir(sys)
[__displayhook__, __doc__, __excepthook__, __interactivehook__, __loader__, __name__, __package__, __spec__, __stderr__, __stdin__, __stdout__, _clear_type_cache, _current_frames, _debugmallocstats
, _enablelegacywindowsfsencoding, _getframe, _git, _home, _xoptions, api_version, argv, base_exec_prefix, base_prefix, builtin_module_names, byteorder, call_tracing, callstats, copyright, displayhook, dllhandle, dont_write_bytecode, exc_info, excepthook, exec_prefix
, executable, exit, flags, float_info, float_repr_style, get_asyncgen_hooks, get_coroutine_wrapper, getallocatedblocks, getcheckinterval, getdefaultencoding, getfilesystemencodeerrors, getfilesystemencoding, getprofile, getrecursionlimit, getrefcount, getsizeof, getswitchinterval
, gettrace, getwindowsversion, hash_info, hexversion, implementation, int_info, intern, is_finalizing, maxsize, maxunicode, meta_path, modules, path, path_hooks, path_importer_cache, platform, prefix, set_asyncgen_hooks, set_coroutine_wrapper, setcheckinterval, setprofile, setrecursionlimit, setswitchinterval, settrace, stderr, stdin, stdout, thread_info, version, version_info, warnoptions, winver]

看下常用的方法:

1、sys.argv 命令行參數

2、sys.exit(n)

3、sys.version

4、sys.maxint

5、sys.path

6、sys.platform

7、sys.stdout.write()

8、sys.

進階第十二課 Python模塊之sys