Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/348.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 蟒蛇3-炉卷和#x27;s month_abbr返回第一个索引为空_Python_Python 3.x - Fatal编程技术网

Python 蟒蛇3-炉卷和#x27;s month_abbr返回第一个索引为空

Python 蟒蛇3-炉卷和#x27;s month_abbr返回第一个索引为空,python,python-3.x,Python,Python 3.x,我刚开始学习蟒蛇3。我有一个问题,我必须迭代所有月份(在Mmm例如Jan)的格式。我用Python3日历来完成事情。下面是示例代码 import calendar all_months = list(calendar.month_abbr) print(all_months) 这段代码工作得很好,但令我惊讶的是,它返回的第一个索引是空字符串。下面是示例输出 [''‘一月’、‘二月’、‘三月’、‘四

我刚开始学习蟒蛇3。我有一个问题,我必须迭代所有月份(在Mmm例如Jan)的格式。我用Python3日历来完成事情。下面是示例代码

 import calendar                                             

 all_months = list(calendar.month_abbr)
 print(all_months)
这段代码工作得很好,但令我惊讶的是,它返回的第一个索引是空字符串。下面是示例输出

[''‘一月’、‘二月’、‘三月’、‘四月’、‘五月’、‘六月’、‘七月’、‘八月’、‘九月’、‘十月’、‘十一月’、‘十二月’]

为什么第一个索引是空字符串?

这是为了允许月份编号从1开始(如文档中所述),因为列表/数组索引从零开始:

这遵循了1月为第1个月的正常惯例,因此 长度为13,
月份\u缩写[0]
空字符串。 [我的重点]


那么,月份
0
的名称是什么?考虑从1开始的日历月数!