Home  >  Article  >  Backend Development  >  How to wrap input commands in python interactive mode

How to wrap input commands in python interactive mode

尚
Original
2019-07-06 09:51:1115621browse

How to wrap input commands in python interactive mode

Let me first introduce to you the method of entering newline/entering multi-line commands in python interactive mode

换行方法 \
如:
>>> print 'aaa'; \
 ... print 'bbb'; \
 ... print 'ccc'
注意;号的使用。

Python itself does not require the end of the statement and the interval; sign , but the ; sign must be used when breaking a line. The last line is not required to have a ; sign, and there will be no error if added.

Let’s take a look at how to wrap the line in the interactive command line of python

>>> is the input prompt of python, and pressing Enter will end the input. So how to enter more than two statements?

Line break method\

>>> print 'aaa'; \
... print 'bbb'; \
... print 'ccc'

Pay attention to the use of ; sign. Python itself does not require the ; sign at the end of statements and intervals, but it must be used when breaking a line. The last line is not required to have a ; sign, and there will be no error if added.

For more Python related technical articles, please visit the Python Tutorial column to learn!

The above is the detailed content of How to wrap input commands in python interactive mode. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn