问题
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:"))
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?
回答1:
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!
Quotting what you get:
Launch python in local or remote(1) virtualenv.
Quickly run selected script or launch PDB.
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).
来源:https://stackoverflow.com/questions/38176401/trouble-with-user-inputs-in-sublime-text