我的代码中有一个子进程,像这样。
child = sp.Popen(os.path.join(temp_undat, undat_binary), stdout=sp.PIPE, stderr=sp.PIPE, encoding='utf-8')
streamdata, err = child.communicate()
rc = child.returncode
...
print(err)
print('<<<>>>')
print('output data end')
print(f'return code: {rc}')
但是当我比较err
和rc
返回码时,它们并不相似,就像万一返回码是unsigned int一样:
16:12:33 Traceback (most recent call last):
16:12:33 File "<string>", line 233, in <module>
16:12:33 File "<string>", line 25, in read_from_dat
16:12:33 ValueError: invalid literal for int() with base 10: ''
16:12:33 undat returned -1
16:12:33
16:12:33 <<<>>>
16:12:33 output data end
16:12:33 return code: 4294967295
我真的不知道为什么它在Python2中可以正常运行,但在Python3中却无法运行。