-2
我對我的樹莓派製作相機程序(代碼)python input()不工作! (樹莓派相機程序)
import picamera
import sys
import time
question=input('do you want to take a picture(pic) take a timed picture(time) or a video(vid)')
if question=='pic':
time=0
elif question=='time':
time=1
elif question=='vid':
print ('coming soon')
sys.exit()
num=0
camera = picamera.PiCamera()
camera.start_preview()
input('press any key to take picture')
if time==1 :
print ('5')
time.sleep(1)
print ('4')
time.sleep(1)
print ('3')
time.sleep(1)
print ('2')
time.sleep(1)
print ('1')
time.sleep(1)
print ('0')
camera.capture(num)
num=num + 1
,當我運行它,它要求
你想拍照( PIC)採取定時圖片(時間)或視頻(VID)
只是因爲它是假設我回答
PIC
然後它給了我這個錯誤
Traceback (most recent call last):
File "/home/pi/Desktop/camera.py", line 5, in <module>
question=input('do you want to take a picture(pic) take a timed picture(time) or a video(vid)')
File "<string>", line 1, in <module>
NameError: name 'pic' is not defined
發生了什麼?
使用'raw_input'而不是'input'。 – CoryKramer 2014-11-05 15:25:30
感謝它現在的工作,現在我只需要啓用我的picamera :) – 2014-11-05 15:29:18
@Cyber,請發表評論作爲答案。這樣做將有助於瀏覽未答覆問題選項卡的人員查詢真正尚未回答的問題。 – Kevin 2014-11-05 15:41:01