Why use Python's os module methods instead of executing shell commands directly?

前端 未结 6 935
耶瑟儿~
耶瑟儿~ 2021-01-29 17:58

I am trying to understand what is the motivation behind using Python\'s library functions for executing OS-specific tasks such as creating files/directories, changing file attri

6条回答
  •  [愿得一人]
    2021-01-29 18:32

    Shell call are OS specific whereas Python os module functions are not, in most of the case. And it avoid spawning a subprocess.

提交回复
热议问题