Execute sys.argv in python 3[1], error: indexError: list index out of range
1. Execute sys.argv in python 3[1], an error is reported: indexError: list index out of range. as shown in Figure 1
PS E:\wwwroot\object> python batch-remove-rediskey.py
Traceback (most recent call last):
File "E:\wwwroot\object\batch-remove-rediskey.py", line 27, in
match = sys.argv[1]+"*"
IndexError: list index out of range
2. sys.argv is the command line option for you to execute the script. sys.argv[0]is the name of the script you are running. All additional options are included in sys.argv[1:]in. Execute: python batch-remove-rediskey.py /tmp. Execution is successful. as shown in Figure 2
PS E:\wwwroot\object> python batch-remove-rediskey.py /tmp
/tmp*
All done
![在 Python 3 中执行 sys.argv[1] 时,报错:IndexError: list index out of range](https://www.shuijingwanwq.com/wp-content/uploads/2022/10/1-4.png)
![sys.argv 代表你执行脚本的命令行选项。sys.argv[0] 是您正在运行的脚本的名称。所有附加选项都包含在 sys.argv[1:] 中。执行:python batch-remove-rediskey.py /tmp。执行成功](https://www.shuijingwanwq.com/wp-content/uploads/2022/10/2-3.png)