问题
After migrating to ipython, I noticed that sometimes return key causes a line break instead of executing the command. For example if I have my cursor before ) in print(), it would result in:
print(
)
How can I make it just run print() in this and other cases?
回答1:
This happens when you are in multiline mode, e.g.
In [200]: for i in range(3):
...: print(i)
...:
You either need to move to the end of the block (<end>) and return twice (or more if editing has accumulated a bunch of blank lines); or use <esc><return>.
It shouldn't happen in single line entry. Wrapped lines maybe. In any case the <end> and <esc> work. The extra key press is the cost of the multiline editing convenience.
来源:https://stackoverflow.com/questions/43070453/make-ipython-always-execute-command-when-i-press-return-key