- 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
- 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 theos.path
module, and if you want to read all the lines in all the files on the command line see thefileinput
module. For creating temporary files and directories see thetempfile
module, and for high-level file and directory handling see theshutil
module. 参见:https://docs.python.org/3/library/os.html
通俗地来说:
- sys用于利用Python编译器的一些变量或函数来完成任务。
- os用于利用操作系统的一些变量和函数(大多经过了重新命名以提高可移植性)来达到目的。
原文地址:https://www.cnblogs.com/lyg-blog/p/8988001.html
时间: 2024-11-10 09:05:05