在ipython中添加换行符 [英] Adding line breaks in ipython
问题描述
如果在iPython或任何多行命令中引入for循环,我该如何返回并为其添加行?我跑了这个:
If introduce a for loop in iPython, or any multi-line command, how do I go back and add lines to it? I ran this:
for row in table.find_all('tr'):
cells = row.find_all('td')
for c,cell in enumerate(cells):
print c,":",cell.get_text().strip()
try:
this = cells[0]
that = cells[1]
the_docket = cells[2]
other_thign = cells[3]
jumble = re.sub('\s+',' ',str(cells[5])).strip()
except:
"Nope"
并意识到我需要为它添加一行,但我不能只在iPython中点击输入,运行该命令的b / c。那么我可以在iPython中编辑那个多行命令吗?
And realized I need to add a line to it, but I can't just hit "enter" in iPython, b/c that runs the command. So can I edit that multi-line command w/in iPython?
推荐答案
%edit
iPython中的魔术功能允许您在您喜欢的编辑器中编辑代码,然后执行它就像直接输入一样。您还可以编辑已经输入到repl中的代码,因为它存储在特殊变量中,例如:
The %edit
magic function in iPython lets you edit code in your favorite editor and will then execute it as if it was typed directly. You can also edit code you've already typed into the repl since it's stored in a special variable, for example:
In [1]: def foo(x):
...: print x
...:
In [2]: %edit _i1
这篇关于在ipython中添加换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!