There is no problem not worth solving, and no technology not worth learning!

Execute sys.argv in python 3[1], error: indexError: list index out of range

在 Python 3 中执行 sys.argv[1] 时,报错: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

在 Python 3 中执行 sys.argv[1] 时,报错:IndexError: list index out of range
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

sys.argv 代表你执行脚本的命令行选项。sys.argv[0] 是您正在运行的脚本的名称。所有附加选项都包含在 sys.argv[1:] 中。执行:python batch-remove-rediskey.py /tmp。执行成功
Figure 2

PS E:\wwwroot\object> python batch-remove-rediskey.py /tmp
/tmp*
All done


Need long-term technical maintenance or remote troubleshooting?

I am a PHP / Go backend engineer with 15+ years of experience, focused on existing system maintenance, bug fixing, performance optimization, server troubleshooting, WordPress maintenance, and small feature iterations.

If your project is facing any of the following issues, we can start with a small troubleshooting task first:

  • ✅ PHP / Laravel / Yii2 legacy systems without active maintenance
  • ✅ Go / Gin backend APIs that need troubleshooting or optimization
  • ✅ Slow, broken, or unstable WordPress websites
  • ✅ Nginx / MySQL / Redis / Linux server issues
  • ✅ CDN / Cloudflare / DNS / HTTPS configuration problems
  • ✅ Long-term remote technical support or part-time maintenance

More details: About Me & Collaboration

WeChat: 13980074657
Email: shuijingwanwq@gmail.com
Telegram: @shuijingwan
GitHub: https://github.com/shuijingwan

评论

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.