How to get to a new line in Python Shell?

前端 未结 7 1667
孤独总比滥情好
孤独总比滥情好 2021-02-02 11:20

In IDLE, say i want to write the following in TWO lines:

x = 3

print x**5

but when i type x = 3 and press enter, it executes the assignment. H

相关标签:
7条回答
  • 2021-02-02 11:40
    x = 3; print x ** 5
    

    should help, but it doesnt matter that its executed the way it is in IDLE.

    0 讨论(0)
  • 2021-02-02 11:41

    Ctrl + Enter enters a new line in Spyder IDE

    0 讨论(0)
  • 2021-02-02 11:43

    after every line put \ mark and press enter

    0 讨论(0)
  • 2021-02-02 11:50

    Use the Ctrl-J key sequence instead of the Enter key to get a plain newline plus indentation without having IDLE start interpreting your code.

    You can find other key sequences that make IDLE easier to use for this type of learning under the Options->Configure IDLE menu.

    0 讨论(0)
  • 2021-02-02 11:52

    To code group of statements, ;\ will work

       list1=[1,2,3]
       list2=[4,5,6]
    
       print list1;\
       print list2
    

    Will print both the lists

    Where as, for Indentation statement, you need :\

      for i in list1:\
      print i
      //double enter
    

    Will show all the elements in the list

    0 讨论(0)
  • 2021-02-02 11:56

    Just open a new file: File > New window. You can run it by clicking run > run module.

    0 讨论(0)
提交回复
热议问题