Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How to execute Python multi-line statements in the one-line at command-line?
There are multiple ways in which you can use multiline statements in the command line in python. For example, bash supports multiline statements, which you can use like −
Example
$ python -c '
> a = True
> if a:
> print("a is true")
> '
Output
This will give the output −
a is true
If you prefer to have the python statement in a single line, you can use the \n newline between the commands.
example
$ python -c $'a = True\nif a: print("a is true");'
Output
This will give the output −
a is true
Advertisements
