如果可能的话,我想直接在shell会话中剪切和粘贴。我在.py文件中有一个简单的with块:
with open('t1_equip.json') as json_file:
data = json.load(json_file)
# Print the type of data variable
print("Type:", type(data))这将很容易地剪切和粘贴到解释器中。但是,如果我尝试直接在bpython会话本身中进行剪切和粘贴,则会抛出错误:
>>> with open('t1_equip.json') as json_file:
... ... data = json.load(json_file)
File "<bpython-input-57>", line 2
... data = json.load(json_file)
^
IndentationError: expected an indented block
>>> ... # Print the type of data variable
Ellipsis
>>> ... print("Type:", type(data))
File "<input>", line 1
... print("Type:", type(data))
^
SyntaxError: invalid syntax我觉得必须有一个简单的工作流程更改,我可以做到这一点只需几个按键。必须不断点击向上箭头来重新插入可以做到这一点,但我们是否可以对整个最后一块执行%hist之类的操作或类似的操作?我怎么才能做到这一点呢?我使用的是zsh和哦-my-zsh和powerlevel10k。
发布于 2021-03-29 00:04:27
不要使用python命令。使用ipython。您可能需要通过pip install ipython安装它。然后使用魔术命令%paste。这将很容易地复制引号块。
pip install ipython #Install
ipython # Opens ipython prompt
%pastehttps://stackoverflow.com/questions/66842427
复制相似问题