需要星期天作为一周的第一天 [英] Need Sunday as the first day of the week

查看:148
本文介绍了需要星期天作为一周的第一天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望星期日为0,但是当使用datetime weeday方法时,它是6:

I would like Sunday to be 0, but when using the datetime weeday methods it's 6:

datetime(2013, 6, 9, 11, 59, 59, 1).weekday()  # this returns 6

我的区域设置是:en_US.UTF-8,所以星期日应该是0(当我在bash提示下运行'locale day'时,它正确地显示'星期日'作为一周的第一天)。 >

My locale is: "en_US.UTF-8" so Sunday should be 0 (when I run 'locale day' at bash prompt, it correctly shows 'Sunday' as first day of the week).

$ locale day
Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday

如何将python显示为星期天作为一周的第一天?

How can I get python to show Sunday as the first day of the week?

(我正在使用一个熊猫时代,并调用 .date 获取数据时间。)

(I'm using a pandas timeseries and calling .date to get the datetimes.)

推荐答案

尝试这样:

(datetime.datetime(2013, 6, 9, 11, 59, 59, 1).weekday() + 1) % 7

这篇关于需要星期天作为一周的第一天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆