What is the difference between sys
and os.sys
in python? I have seen many projects using sys
when they have imported os
. When I tried dir(sys)
and dir(os.sys)
they had same functions and their output was same.
I often see code using sys.exit
like this, rather than using os.sys.exit
, but both do the same thing.
import os
import sys
sys.exit()
开发者_JAVA技巧
os.sys
is os
's "private" name for sys
; Python does not hide imports performed in another module. You should not depend on its existence, and should instead import sys
directly yourself.
精彩评论