Python中sys和os模块的区别

Posted 心有事焉 勿忘勿助

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python中sys和os模块的区别相关的知识,希望对你有一定的参考价值。

  1. sys: This module provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter. It is always available. 参见:https://docs.python.org/3/library/sys.html
  2. os:This module provides a portable way of using operating system dependent functionality. If you just want to read or write a file see open(), if you want to manipulate paths, see the os.path module, and if you want to read all the lines in all the files on the command line see the fileinput module. For creating temporary files and directories see the tempfile module, and for high-level file and directory handling see the shutil module. 参见:https://docs.python.org/3/library/os.html

通俗地来说:

  1. sys用于利用Python编译器的一些变量或函数来完成任务。
  2. os用于利用操作系统的一些变量和函数(大多经过了重新命名以提高可移植性)来达到目的。

以上是关于Python中sys和os模块的区别的主要内容,如果未能解决你的问题,请参考以下文章

python之os和sys模块的区别

python中os模块与sys模块的区别

Python中os与sys模块的区别

Python中os与sys两模块的区别

python中os与sys作用与区别

python中sys和os的区别