Answers for "python get command line"

11

read argument from terminal

#!/usr/bin/python

import sys

print 'Number of arguments:', len(sys.argv), 'arguments.'
print 'Argument List:', str(sys.argv)

#Terminal
# $ python test.py arg1 arg2 arg3

#print
#Number of arguments: 4 arguments.
#Argument List: ['test.py', 'arg1', 'arg2', 'arg3']
Posted by: Guest on May-22-2020
1

shell command python

import subprocess
subprocess.run(["ls", "-l"])
Posted by: Guest on June-02-2020
1

command for python shell

write python and press enter in terminal. 

A Python Prompt comprising of three greater-than symbols >>> appears.
Posted by: Guest on October-07-2021

Code answers related to "python get command line"

Python Answers by Framework

Browse Popular Code Answers by Language