Notifications
                
            
                Clear all
    
            
        
									1                                
                                27/03/2024 5:26 pm
								 Topic starter
	                                
                            I'm trying to write a Python script that can accept command-line arguments. Can someone provide a simple example of how to access command-line arguments in a Python script, and explain how it works?
								1 Answer                            
                            
									0                                
                                02/09/2024 10:49 pm
								                                
                            A quick way to access command-line arguments in Python is by using the sys module. Here’s a basic example:
import sys
print("Script Name:", sys.argv[0])
print("First Argument:", sys.argv[1])
Just remember that sys.argv is a list, where the first item (sys.argv[0]) is always the script's name.
