Sublime Text 中的用户输入问题 [英] Trouble with User Inputs in Sublime Text

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

问题描述

我正在尝试在 Sublime Text 中使用 Python (2) 编写一个简单的计算器,其中包括询问用户第一个数字、运算,然后是第二个数字.然而,每次我尝试在 Sublime 中执行代码时,我都无法通过第一个用户输入.

I'm trying to code a simple calculator using Python (2) in Sublime Text that consists of asking the user for the first number, the operation, then the second number. However, every time I try to execute the code in Sublime, I can't get past the first user input.

num1 = int(raw_input("Enter your first number:"))
operation = raw_input("Enter your operation:")
num2 = int(raw_input("Enter your second number:"))

这在 IDLE 中有效,即我在输入数字后按 Enter 并提示进行操作.在 Sublime 中是否有不同的方法来做到这一点?

This works in IDLE, i.e. I hit enter after I enter a number and it prompts for an operation. Is there a different way to do this in Sublime?

推荐答案

Sublime text 不支持从控制台输入,它只是一个输出控制台,反正有办法,你可以使用 SublimeREPL.你会得到一个像控制台一样的完整的 IDLE 嵌入到 sublime 文本中!

Sublime text doesn't support input from the console, it's just an out console, anyways there's a way around, you can use SublimeREPL. You get a full IDLE like console embedded right into the sublime text!

引用你得到的:

在本地或远程 (1) virtualenv 中启动 python.

Launch python in local or remote(1) virtualenv.

快速运行选定的脚本或启动 PDB.

Quickly run selected script or launch PDB.

使用带有历史记录和多行输入的 SublimeText2 Python 控制台.

Use SublimeText2 Python console with history and multiline input.

你可以从包控制安装它(我猜你已经有了包控制!如果没有从这里获得它).

You can install it from package control(I guess you already have package control! If not get it from here).

这篇关于Sublime Text 中的用户输入问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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