Python Tutorial for Beginners 46 – Command Line Arguments in Python with argparse

///Python Tutorial for Beginners 46 – Command Line Arguments in Python with argparse

Python Tutorial for Beginners 46 – Command Line Arguments in Python with argparse

FavoriteLoadingAdd to favorites

In this Python Programming Tutorial for Beginners video I am going to show you How to use argparse to parse python scripts parameters.So basically we will discuss: What are command line arguments, Why we use command line arguments, How to parse command line arguments with Python. argparse is a in build module in python using which we an pass command line arguments with our python script.The argparse module makes it easy to write user-friendly command-line interfaces. The program defines what arguments it requires, and argparse will figure out how to parse those out of sys.argv. So we just need to import argparse into out python program and use it.
So let us see Build Command Line Interface using Argparse in Python.Parsing Command-Line Argument in Python

#PythonTutorialforBeginners #ProgrammingKnowledge #LearnPython #PythonCourse.
——————-Online Courses to learn—————————-
Blockchain Course –
Big Data Hadoop Course –
Java –
C++ –
AngularJS –
Python –
C-
Android –
Linux –
AWS Certified Solutions Architect –
Modern React with Redux –
MySQL –
———————-Follow———————————————
My Website –
My Blog –
My Facebook Page –
Google+ –
Twitter –
Pinterest –
Text Case Converter –
————————-Stuff I use to make videos ——————-
Stuff I use to make videos
Windows notebook –
Apple MacBook Pro –
Ubuntu notebook –
Desktop –
Microphone –
notebook mouse –
——————Facebook Links —————————————-

source

By |2019-08-14T22:02:06+00:00August 14th, 2019|Python Video Tutorials|8 Comments

8 Comments

  1. ProgrammingKnowledge August 14, 2019 at 10:02 pm - Reply
  2. MrBamshy August 14, 2019 at 10:02 pm - Reply

    Thank you very much for your teaching methodology. The building block approach is very helpful. Carefully explaining each step in the building block is awesome. Thank you again!

  3. Sai kumar Naik August 14, 2019 at 10:02 pm - Reply

    Wow ! that's an awsome explanation sir. Kudos! and thank you.

  4. MalezaCaminante August 14, 2019 at 10:02 pm - Reply

    whenever i try to run any arg parse script it automatically closes, what am i doing wrong? please help.

  5. Charles Bovalis August 14, 2019 at 10:02 pm - Reply

    That was a great introduction on how to use argparse. However, I have a more challenging situation to solve: Say I want to have a command line python script that must accept several arguments, each argument prefixed with a specific letter and if possible the value(s) entered for each parameter must also pass some sort of validation.
    example: Say a script must accept a data-center argument ( -d ) that must be either: DataCenter1, Datacenter2, Datacenter3 or ALL of them separated by comma, and say another argument, say a Severity level issue ( -s ) that accepts any of: 1,2,3,4 … So we can invoke a script as: my_script.py -d Datacenter1 -s 4
    Can we still user the argparse module to accomplish this ?
    Thank you for your time.

  6. Abdul Sami August 14, 2019 at 10:02 pm - Reply

    roughly how much a person can earn by learning java

  7. Arjun Sonani August 14, 2019 at 10:02 pm - Reply

    Hey how many (approximately) videos are left in this series , if I want to start learning AI

  8. ashish sinha August 14, 2019 at 10:02 pm - Reply

    Bro after course plz provide project in python tutorial

Leave A Comment

*