简体   繁体   English

raw_input在树莓派上挂在python2.7.3上

[英]raw_input hang on python2.7.3 on raspberry pi

I am building a small robot based on a raspberry pi and a pic microcontroller (pic16f1937). 我正在建立一个基于树莓派和图片微控制器(pic16f1937)的小型机器人。 Basically raspi is taking a picture, looks for a specific object (a green ball for example), generate commands (rotation to the left or to the right for some degrees, go farward, go backward, take the object, free the object) and send them on a serial (ttl rs232) link to microcontroller. 基本上raspi拍照,寻找特定的物体(例如一个绿色的球),生成命令(向左或向右旋转一定程度,向前,向后旋转,拍摄物体,释放物体)并通过串行(ttl rs232)链接将其发送到微控制器。

Raspi program is made using Geany 1.22 , Python 2.7.3 and opencv. Raspi程序使用Geany 1.22,Python 2.7.3和opencv制作。

Pic program is on hitech c, but is irelevant at this moment. Pic程序在高科技c上,但目前不相关。

My problem (at this moment) is that I want to use more than one objects and I want to be asked by raspi if I want it to continue bringing me more objects after every object it brings. 我的问题(此刻)是我想使用多个对象,并且希望raspi询问我是否要继续为每个对象带来更多的对象。 For that i am using : 为此,我正在使用:

continue=''
continue=raw_input('do you want to continue? y=yes   n=no')
if(continue):{do some stuff}

But the programs pauses/hangs on the line containing raw_input instruction. 但是程序在包含raw_input指令的行上暂停/挂起。 No error is displayed and I have to stop it. 没有错误显示,我必须停止它。

Do you have any idea about what could be the problem? 您对可能的问题有任何想法吗? If yes, please help me. 如果是,请帮助我。

Actually, continue is a reserved word in python. 实际上, continue是python中的保留字。 So there is no way this could ever work, you would get a SyntaxError. 因此,这不可能,您将得到一个SyntaxError。

Also, raw_input returns a string of whatever was typed in, so unless enter was pressed immediately, the string will be non-empty, and will evaluate as True (even if 'n' was typed). 另外,raw_input返回的字符串是键入的任何内容,因此,除非立即按下enter键,否则该字符串将为非空,并且将被评估为True(即使键入了'n')。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM