Eri*_*ric 1 python bit-shift type-conversion
我使用os.system来运行make命令
os.system('make -C mydir/project all')
Run Code Online (Sandbox Code Playgroud)
我想看看make是否失败.系统文档指出返回代码的格式与wait()
Wait for completion of a child process, and return a tuple containing its pid
and exit status indication: a 16-bit number, whose low byte is the signal number
that killed the process, and whose high byte is the exit status (if the signal
number is zero); the high bit of the low byte is set if a core file was produced.
Run Code Online (Sandbox Code Playgroud)
所以如果make(或另一个应用程序)返回-1,我必须将0xFFxx(我真的不关心被调用的pid)转换为-1.右移后,我得到0xFF,但我无法将其转换为-1,它总是打印255.
那么,在python中,如何将255转换为-1,或者如何告诉解释器我的255实际上是8位有符号整数?