How to avoid os.system() printing out return value in python

前端 未结 4 903
一整个雨季
一整个雨季 2021-01-20 18:29

I\'m using Python to call bash to execute another bash script:

begin = int(sys.argv[1])
result = os.system(\"/tesladata/isetools/cdISE.bash %s\" %begin)
         


        
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-20 18:56

    You can just throw away any output by piping to /dev/null.

    begin = int(sys.argv[1])
    result = os.system("/tesladata/isetools/cdISE.bash %s > /dev/null" %begin)
    

    If you don't want to display errors either, change the > to 2&> to discard stderr as well.

提交回复
热议问题