python使用format出现tuple index out of range报错的可能原因及解决

关于python 使用format格式化输出时出现IndexError: tuple index outof range报错的原因及解决方法

本人python小白,希望用博客记录下自己犯的错误供自己日后编程和大家编程中参考和防范。
《python使用format出现tuple index out of range报错的可能原因及解决》

上图是本人变成时出现报错的截图,该报错:tuple index out of range意为元组指数超过范围。在这里format里面的参数和前面的槽是一一对应的,因此当槽的个数大于参数时就会出现报错。解决方法如下图:

《python使用format出现tuple index out of range报错的可能原因及解决》

    原文作者: 汉诺塔问题
    原文地址: https://blog.csdn.net/qq_41672415/article/details/82889291
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞