我已经明白,当涉及到GPIO上的SPI/I2C时,位敲击是一种可怕的做法.为什么这样?
subprocess.call
当我得到键盘中断(ctrl-c)时,我需要停止使用Python 创建的进程
问题是p在完成执行之前没有分配给它的值
p = subprocess.call(cmd)
所以我不能os.kill
用来杀死它.另外,shell=True
因为原因无法使用.
我想做的是:
try:
p = subprocess.call(cmd)
except KeyboardInterrupt:
os.kill(p.pid,signal.SIGTERM)
sys.exit('exited after ctrl-c')
Run Code Online (Sandbox Code Playgroud) 当我从emacs中的shell/eshell/term运行编译指令时,变量的名称在shell中显得很奇怪.
下面是一个示例代码(带有一些随机错误)和编译时的输出:
#include iostream
#include cstdlib
int main (void)
{
cscdsd ;//some random error
return ;
}
//shell o/p:
g++ new.cc
new.cc: In function â\200\230int main()â\200\231:
new.cc:7: error: â\200\230cscdsdâ\200\231 was not declared in this scope
new.cc:8: error: return-statement with no value, in function returning â\200\230intâ\200\231
~/codes $
Run Code Online (Sandbox Code Playgroud)
我想通过的是\ 200\230和\ 200\231表示变量或函数名称的开头和结尾.任何想法发生了什么或如何摆脱它?