在 Python 3 中执行 sys.argv[1] 时,报错:IndexError: list index out of range
1、在 Python 3 中执行 sys.argv[1] 时,报错:IndexError: list index out of range。如图12、sys.argv 代表你执行脚本的命令行选项。sys.argv[0] 是您正在运行的脚本的名称。所有附加选项都包含在 sys.argv[1:] 中。执行:python batch-remove-rediskey.py /tmp。执行成功。如图2
<pre class="wp-block-syntaxhighlighter-code">
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 <module>
match = sys.argv[1]+"*"
IndexError: list index out of range
</pre>
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)