-1

How to get information after call to file? Example Input : cmd > python file.py getme

How i can read the string 'getme'?

dauzduz TV
  • 69
  • 7

2 Answers2

0

sys.argv represents the command line arguments. Note the the first element (index 0) is the name of the script. So, in your case:\

import sys
arg = sys.argv[1] # this will contain "getme"
Mureinik
  • 297,002
  • 52
  • 306
  • 350
0

There is a lib to do that argparse, it is easy to use and offers a ruge ways to personalize your parameters.