当前位置:首页 > 编程技术 > 正文

如何从日期识别周六周末

如何从日期识别周六周末

从日期识别周六和周日,你可以使用以下几种方法: 使用编程语言 Python 示例:```pythonfrom datetime import datetimedef g...

从日期识别周六和周日,你可以使用以下几种方法:

使用编程语言

Python 示例:

```python

from datetime import datetime

def get_weekday(date_str):

date_obj = datetime.strptime(date_str, '%Y-%m-%d')

return date_obj.strftime('%A')

date_input = '2023-01-01' 示例日期

weekday = get_weekday(date_input)

print(f"The day of the week for {date_input

最新文章