how to convert sys.argv strings into list

I am parsing long urls through sys.argv

format parsing is : "url1 ", "url2", "url3"

and output values trying to convert into list but get results like

url1, url2, url3

parsing urls :


output is, not valid list


import sys

test = sys.argv[1]


parsing command

 python  "",""

1 answer

  • answered 2019-07-17 23:42 Gwang-Jin Kim

    import sys
    test = sys.argv[1:] # you want all arguments so slice to the end, 
    # test is then already a list
    print(test) # so no need to pack `test` into a list here, because it IS a list

    Call it then like this

     python  "" ""