Python raw_input不接受输入 [英] Python raw_input not taking input

查看:227
本文介绍了Python raw_input不接受输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始学习python,对在命令行(终端mac os x)上运行它感到厌倦.我想要一个可以很好地在其中编写代码的环境,并且仅在完成部分代码后才能运行该代码,而不是像在shell中那样逐行地运行该代码.我决定使用Xcode,因为界面简洁明了,并遵循

I've recently started learning python and got tired of running it on the command line (terminal mac os x). I wanted an environment that I could code nicely in and run that code only when pieces of it were done, not line-by-line as in the shell. I decided to use Xcode as the interface is clean and simple, and followed this tutorial to set up Xcode so that I could run python scripts.

我的问题是,当我使用raw_input()然后单击 run 时,我无法键入要传递给它存储的变量的值.以以下简单行为例:

My problem is that when I use raw_input() and then click run, I can't type a value to pass to the variable it's stored in. Take this simple line for example:

word = raw_input(输入单词:")

word = raw_input("Enter a word: ")

稍后在程序中,将打印word.当我在Xcode上单击 run 时,在控制台中按预期显示提示:

Later on in the program, word is printed. When I click run on Xcode, the prompt shows up as expected in the console:

输入一个单词:

Enter a word:

但是,我无法在其中键入任何内容,光标在闪烁,因此我知道它正在响应,但是当我键入一个值时,什么也没有发生.我不确定这里有什么问题,希望你们中的一个可以帮助我.

However, I can not type anything into it, the cursor is blinking so I know it is responding but when I type a value, nothing happens. I'm not sure what is wrong here, hopefully one of you can help me out.

推荐答案

如果您真的想使用IDE进行Python开发,请访问 Aptana Studio 3 .

If you really want to use an IDE for Python development, go for Aptana Studio 3 .

完成Pydev设置后,这非常容易有关此内容,请参见Pydev设置.

Once you are done with Pydev setup which is very easy Refer this for Pydev Setup.

在运行需要一些命令行输入的脚本之前,您可以单击运行按钮旁边的小箭头按钮,它将为您提供带有不同选项的下拉菜单.单击run configurations,然后单击名为Arguments的选项卡,然后在字段名称Program Arguments中输入您的参数.单击申请",您就可以开始了.

Before running a script which expects some command line inputs you can click on the small arrow button adjacent to run button, it will give you a drop down menu with different options. Click on run configurations and then click on a tab named Arguments and enter your parameters there in the field names Program Arguments. Click on apply and you are good to go.

下次您需要运行代码时,只需单击运行,它将自动获取您在上述选项中指定的参数.

Next time you need to run the code just click on run and it will automatically fetch arguments that you have specified in the option above.

希望获得帮助.

这篇关于Python raw_input不接受输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆