知行编程网知行编程网  2022-11-17 02:00 知行编程网 隐藏边栏  25 
文章评分 0 次,平均分 0.0
导语: 本文主要介绍了关于python的sys模块在哪的相关知识,希望可以帮到处于编程学习途中的小伙伴

python的sys模块在哪里

当前使用的python版本: Python 2.7.6


sys是python自带模块.

利用 import 语句输入sys 模块。

执行 import sys 时,python 在 sys.path 变量中列出的目录中查找 sys 模块文件。然后运行这个模块的主块中的语句进行初始化,然后就可以了

可以使用模块了 。


sys模块常见函数

你可以通过 dir() 方法查看模块中可用的方法。结果如下,很多我没用过,所以简单介绍一下我用过的几个方法。

$ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> 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']

本文为原创文章,版权归所有,欢迎分享本文,转载请保留出处!

知行编程网
知行编程网 关注:1    粉丝:1
这个人很懒,什么都没写
扫一扫二维码分享