ホーム

Get number of arguments with len (sys.argv) - python

environment

  • python
  • len(sys.argv)

Thing you want to do

The details are boring, but you can pass arguments when you run python on the command line. It is a program that obtains the number of arguments.

Implementation

# -*- coding: utf-8 -*-
import sys

if __name__=='__main__':

    num = len(sys.argv)
    count = 1

while count < num:
    print sys.argv[count]
    count += 1
Pocket
LinkedIn にシェア

-ホーム

Copyright© off.tokyo , 2021 All Rights Reserved Powered by AFFINGER5.