简体   繁体   中英

How to pass command line to save into list

How to pass command line to save into list

Disclaimer Please dont say print (ARGV1[0])

import sys
ARGV1 = []
for ARGV in sys.argv[2:]:
    ARGV1.append(sys.argv[2:])
print (ARGV1)

My Out

[['2', '3', '4'], ['2', '3', '4'], ['2', '3', '4']]

My Expected out

['2', '3', '4']

Disclaimer Please dont say print (ARGV1[0])

Just do

ARGV1 = sys.argv[2:]

Since you have 3 values in input its adding same list 3 times.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM