python input() not working! (raspberry pi camera program) -
i on raspberry pi making photographic camera programme (code)
import picamera import sys import time question=input('do want take picture(pic) take timed picture(time) or video(vid)') if question=='pic': time=0 elif question=='time': time=1 elif question=='vid': print ('coming soon') sys.exit() num=0 photographic camera = picamera.picamera() camera.start_preview() input('press key 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
and when ran it, asked
do want take picture(pic) take timed picture(time) or video(vid)
just suppose replied
pic
then gave me error
traceback (most recent phone call last): file "/home/pi/desktop/camera.py", line 5, in <module> question=input('do want take picture(pic) take timed picture(time) or video(vid)') file "<string>", line 1, in <module> nameerror: name 'pic' not defined
what happened?
as cyber said in comments, utilize python's raw_input() function vis-a-vis input.
raw_input() take stdin str type until user hits enter.
question = raw_input("do want take picture(pic) take timed picture(time) or video(vid)?")
python
No comments:
Post a Comment