I've been doing some exercises for AI course and I to get arguments to my code directly from the command line, for example python solution.py resolution_examples/small_example.txt. I now in java you can pass arguments to main fun via command line, but can you do the same thing in python?
            Asked
            
        
        
            Active
            
        
            Viewed 627 times
        
    -2
            
            
        
        bornaZbodulja
        
- 37
 - 4
 - 9
 
- 
                    1Does this answer your question? [How to read/process command line arguments?](https://stackoverflow.com/questions/1009860/how-to-read-process-command-line-arguments) – SDS0 Apr 23 '20 at 12:42
 
2 Answers
0
            sys module has attribute argv which contains all command line parameters.
import sys
print(sys.argv)
For fast handling, that should be enough but when you need a bit more control over cli parsing, standard library has lib called argparse: https://docs.python.org/3/library/argparse.html
        rasjani
        
- 7,372
 - 4
 - 22
 - 35