我正在尝试使用Python在Raspberry Pi上实现的功能中拍照,但是由于在Linux上传输字符串(尤其是从shell传输)的棘手情况,当我尝试运行时遇到错误此代码:
#PROCEDURE TO TAKE PHOTO WITH DEFAULT CAMERA ON RASPBERRY PI
import subprocess
import time
def pyraspistill():
#COMMENT THE QUESTION OUT FOR AUTOMATION BUT THEN CHECK OUT sys
name = str(input("What would you like to call the image:\n\n"))
subprocess.call(['/usr/bin/raspistill','-o',name + str(time.time()) + ".jpg"])
pyraspistill()
响应: 您想如何称呼图片:
picture
Traceback (most recent call last):
File "camera.py", line 8, in <module>
pyraspistill()
File "camera.py", line 6, in pyraspistill
name = str(input("What would you like to call the image:\n\n"))
File "<string>", line 1, in <module>
NameError: name 'picture' is not defined
我在做什么错?我该如何改善? Linux Shell上的字符串会出现什么情况?