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

问题描述

我使用 Sublime Text 2,但是当我的代码要求用户输入时,它不会让我输入任何值.(换句话说:Python 中的 input() 和 Ruby 中的 gets 无法正确提示我输入.

I use Sublime Text 2 but it won't let me enter any value when my code asks for user input. (In other words: input() in Python and gets in Ruby fail to correctly prompt me for input).

Python 抛出一个 EOFError 错误(当用户没有输入任何内容时你会得到什么).

Python throws an EOFError error (what you get when user doesn't enter anything).

简单的 USER INPUT 对我来说在 Sublime Text 2 中不起作用.

Simply USER INPUT isn't working in Sublime Text 2 for me.

例如

try:
    text = input('Enter something: ')
    print text
except EOFError:
    print('\nEOFError')

=> Enter something: #cannot enter anything to var "text"
=> EOFError
=> [Finished]

推荐答案

Sublime text 不支持.但是你可以通过使用 SublimeREPL 来解决它(至少在 python 中),我用它来做所有事情,它工作得很好.不过,它有点难,因为该选项卡仍然可以像普通的 sublime 选项卡一样进行编辑(有好有坏)...

Sublime text doesn't support that. But you can get around it (at least in python) by using SublimeREPL, I use this for everything, it works pretty great. Its a little cooky though, as the tab is still editable like a normal sublime tab (which is good and bad)...

它还允许您在多个选项卡中运行解释器,它基本上很棒.

It also allows you to run the interpreter in multiple tabs, its basically awesome.

要安装它,您需要 package control 这使您可以轻松安装插件.要获取它,请转到此处,然后按照说明进行操作.完成后:

To install it you need package control this lets you easily install plugins. To get it go here, and follow the instructions. Once thats done:

  • 在 Sublime 中按 + + (ST 中的 linux 命令用于转到任何内容").
  • 输入安装",
  • 点击sublime package control: install package".
  • 然后选择SublimeREPL.它会自动安装.
  • 要使用它,请从菜单转到 Tools>sublimerepl>python.
  • in Sublime press + + (linux command in ST for 'goto anything').
  • Type in 'install',
  • click on 'sublime package control: install package'.
  • Then select SublimeREPL. It will install it automatically.
  • To use it go to Tools>sublimerepl>python from the menus.

要制作默认构建系统 SublimeREPL,您可以按照这些 说明.

To make the default build system SublimeREPL, you can follow these instructions.

这篇关于Sublime Text 2 控制台输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 10:59