最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jupyter notebook - Pasting python command after for loop - Stack Overflow

programmeradmin0浏览0评论

I try to paste several lines of python commands after for loop in Jupyter notebook. However, and my code has the follwoing configuration:

    for v in var:
    First line 
    second line
    third line
    ...

without the required indentation of for loop. How to paste the lines (first, second, ...) after for command to have the following indentation:

    for v in var:
        First line 
        second line
        third line
        ...

I try to paste several lines of python commands after for loop in Jupyter notebook. However, and my code has the follwoing configuration:

    for v in var:
    First line 
    second line
    third line
    ...

without the required indentation of for loop. How to paste the lines (first, second, ...) after for command to have the following indentation:

    for v in var:
        First line 
        second line
        third line
        ...
Share Improve this question asked Feb 5 at 19:35 H. KhaniH. Khani 1113 bronze badges 4
  • 4 highlight the lines to be indented and press tab. – Mark Tolonen Commented Feb 5 at 19:40
  • @MarkTolonen is right - the pasted code will preserve whatever indentation it had when copied, so you'll have to fix it yourself. Or, if possible, properly format the source of the code before copying it. – JRiggles Commented Feb 5 at 20:05
  • Thanks, do you mean I have to press manually spaces in each line before the command? It seems unusual and would take a lot of time. – H. Khani Commented Feb 5 at 20:14
  • 1 No, you dont need to manually press spaces in each line. Just do what Mark suggested in his comment – Cincinnatus Commented Feb 5 at 20:16
Add a comment  | 

1 Answer 1

Reset to default 1

For Jupyter notebook the keybind to change indentation is CTRL+ { and CTRL + }. Highlight the lines you wish to change.

发布评论

评论列表(0)

  1. 暂无评论