Numbers passed as command line arguments in python not interpreted as integers

前端 未结 6 1098
有刺的猬
有刺的猬 2020-12-10 10:42

I am familiar with C, and have started experimenting in python. My question is regarding the sys.argv command. I\'ve read it is used for a command line interpre

6条回答
  •  孤街浪徒
    2020-12-10 11:13

    sys.argv items are always strings. you should cast them to int with int(a).

    You can also use third party libraries for handling CLI arguments such as OptParse.

提交回复
热议问题