Command Line Arguments in Python
Open the following as this in cmd:
python filename.py argument
from sys import argv
if len(argv) == 2:
print(f"Hello, {argv[1]}!")
else:
print("Hello, World!")
# to see what is there in argv
for arg in argv:
print(arg)
Comments
Post a Comment
Write something to CodeWithAbdur!