
Python版本目前使用: Python 2.7.6
sys是python自带的模块.
利用 import 输入sys语句 模块。
执行import时 sys后, python在 sys.path 在变量中列出的目录中寻找 sys 模块文件。然后将该模块的主要块中的句子初始化,然后进行初始化
模块可以使用 。
常见的sys模块函数
模块中可用的方法可以通过dir()检查. 结果如下, 很多我都没用过, 所以我只是简单介绍一些我用过的方法.
$python Python2.7.6(default,Oct262016,20:30:19) [GCC4.onlinux28.4 Type"help","copyright","credits"or"license"formoreinformation. >>>importsys >>>dir(sys) ['__displayhook__','__doc__','__excepthook__','__name__','__package__','__stderr__','__stdin__',' __stdout__', '_clear_type_cache','_current_frames','_getframe','_mercurial','_multiarch','api_version','argv', 'builtin_module_names','byteorder','call_tracing','callstats','copyright','displayhook', 'dont_write_bytecode', 'exc_clear','exc_info','exc_type','excepthook','exec_prefix','executable','exit','flags','float_info', 'float_repr_style','getcheckinterval','getdefaultencoding','getdlopenflags','getfilesystemencoding', 'getprofile','getrecursionlimit','getrefcount','getsizeof','gettrace','hexversion','long_info', 'maxint', 'maxsize','maxunicode','meta_path','modules','path','path_hooks','path_importer_cache','platform', 'prefix', 'ps1','ps2','py3kwarning','pydebug','setcheckinterval','setdlopenflags','setprofile', 'setrecursionlimit', 'settrace','stderr','stdin','stdout','subversion','version','version_info','warnoptions']
更多技术请关注Python视频教程。