相关疑难解决方法(0)

sys.argv [1]在脚本中的含义

我现在正在教自己Python,只是想简单地说(参考下面的例子)sys.argv [1]代表什么.它只是要求输入吗?

#!/usr/bin/python3.1

# import modules used here -- sys is a very standard one
import sys

# Gather our code in a main() function
def main():
  print ('Hello there', sys.argv[1])
  # Command line args are in sys.argv[1], sys.argv[2] ..
  # sys.argv[0] is the script name itself and can be ignored

# Standard boilerplate to call the main() function to begin
# the program.
if __name__ == '__main__':
  main()
Run Code Online (Sandbox Code Playgroud)

python

135
推荐指数
6
解决办法
37万
查看次数

标签 统计

python ×1