开发者

What is the difference between sys and os.sys

开发者 https://www.devze.com 2023-03-15 19:00 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消