https://docs.python.org/3/library/sys.html
This module provides access to some objects used or maintained by the interpreter and to functions that interact strongly with the interpreter.
import sys # Dynamic objects (selected). sys.argv # command line arguments; argv[0] is the script pathname if known sys.path # module search path (a list of strings) # sys.path[0] is the script directory, else '' sys.modules # dictionary of loaded modules sys.stdin # standard input file object sys.stdout # standard output file object sys.stderr # standard error object; used for error messages
# Static objects (selected). sys.executable # absolute path of the executable binary of the Python interpreter sys.maxint # the largest supported integer sys.version # the version of this interpreter as a string sys.platform # platform identifier sys.prefix # prefix used to find the Python library
# Functions (selected). sys.exit() # exit the interpreter by raising SystemExit # sys.exit(0) is a success, sys.exit(1) is a failure sys.getrefcount() # return the reference count for an object (plus one :-) sys.getrecursionlimit() # return the max recursion depth for the interpreter sys.getsizeof() # return the size of an object in bytes sys.setrecursionlimit() # set the max recursion depth for the interpreter
#!/usr/bin/python # script.py import sys print(sys.argv)
$ ./script.py 12 34 ['./script.py', '12', '34'] $ python3 script.py 12 34 ['script.py', '12', '34']