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

前端 未结 6 1092
有刺的猬
有刺的猬 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

    In Python, strings are not implicitly converted to integers. Try

    num1 = int(sys.argv[1])
    This would represent the numerical value of the number, not its string representation.
    

提交回复
热议问题