Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python code as arguments

How to pass a piece of code as arguments to python?

I tried like this, but it didn't work.

$ python3 'print("hello world")'

can't open file 'print(hello': [Errno 2] No such file or directory

like image 328
shilk Avatar asked Mar 21 '26 16:03

shilk


2 Answers

python -c 'print("hello world")'

like image 122
bluepnume Avatar answered Mar 23 '26 06:03

bluepnume


Try

python3 -c 'print("hello world")'
like image 44
Loïc Séguin-C. Avatar answered Mar 23 '26 06:03

Loïc Séguin-C.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!