What can lead to “IOError: [Errno 9] Bad file descriptor” during os.system()?

前端 未结 2 730
说谎
说谎 2020-12-05 06:03

I am using a scientific software including a Python script that is calling os.system() which is used to run another scientific program. While the subprocess is

2条回答
  •  庸人自扰
    2020-12-05 06:55

    You can get this error if you use wrong mode when opening the file. For example:

        with open(output, 'wb') as output_file:
            print output_file.read()
    

    In that code, I want to read the file, but I use mode wb instead of r or r+

提交回复
热议问题