小编Jab*_*oto的帖子

猜测日期格式python

我正在 Python 模块中编写一个方法,它试图让用户的生活更轻松。此方法实现在该日历中创建事件。

def update_event(start_datetime=None, end_datetime=None, description=None):
'''
Args:
  start_date: string datetime in the format YYYY-MM-DD or in RFC 3339
  end_date: string datetime in the format YYYY-MM-DD or in RFC 3339
  description: string with description (\n are transforrmed into new lines)
'''
Run Code Online (Sandbox Code Playgroud)

如果用户指定 start_date 或 end_date,则应进行检查以确定日期是 YYYY-MM-DD 格式还是日期时间 RFC 3339 格式。

if (start_date is not None):
    # Check whether we have an date or datetime value
    # Whole day events are represented as YYYY-MM-DD
    # Other events are represented as …
Run Code Online (Sandbox Code Playgroud)

python datetime exception strptime

1
推荐指数
1
解决办法
511
查看次数

标签 统计

datetime ×1

exception ×1

python ×1

strptime ×1