I'd like to simply execute a Python command without having to write a script or enter the interpreter. Is there a way that I could run something like:
python --execute "pow(12.31351,2)"
And have it simply print the result?
you can use -c arguments,like python -c "print 123",see python --help
python -c "print 123"
usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
-c cmd : program passed in as string (terminates option list)
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
3 years ago