Skip to content
Back to skills

Python日期字符串标准化转换函数

ASecurity

编写Python函数,将包含或不包含时间部分的日期字符串(如'2023/6/26 15:00'或'2023/6/26')统一转换为datetime.date对象。

  • 611 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
educationpython

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill 'python日期字符串标准化转换函数' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Python日期字符串标准化转换函数?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Python日期字符串标准化转换函数
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-python-8da5547e/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-python-8da5547e)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "2ac2773d-067e-488b-b43f-c1162b5c684f"
name: "Python日期字符串标准化转换函数"
description: "编写Python函数,将包含或不包含时间部分的日期字符串(如'2023/6/26 15:00'或'2023/6/26')统一转换为datetime.date对象。"
version: "0.1.0"
tags:
  - "python"
  - "datetime"
  - "parsing"
  - "function"
  - "date-conversion"
triggers:
  - "编写一函数处理日期和时间"
  - "日期字符串转date对象"
  - "如何统一转换不同格式的日期"
  - "python日期解析函数"
---

# Python日期字符串标准化转换函数

编写Python函数,将包含或不包含时间部分的日期字符串(如'2023/6/26 15:00'或'2023/6/26')统一转换为datetime.date对象。

## Prompt

# Role & Objective
编写一个Python函数,用于将日期字符串转换为datetime.date对象。

# Operational Rules & Constraints
1. 输入字符串可能包含时间部分(例如 "2023/6/26 15:00"),也可能不包含(例如 "2023/6/26")。
2. 函数必须能够处理这两种输入情况。
3. 输出结果必须是datetime.date对象。
4. 日期格式通常为 "YYYY/M/D" 或 "YYYY/M/D H:M"。

# Interaction Workflow
1. 接收日期字符串作为输入。
2. 尝试按照带时间的格式(如 "%Y/%m/%d %H:%M")解析字符串。
3. 如果解析失败,则尝试按照仅日期的格式(如 "%Y/%m/%d")解析字符串。
4. 返回解析后的datetime.date对象。

## Triggers

- 编写一函数处理日期和时间
- 日期字符串转date对象
- 如何统一转换不同格式的日期
- python日期解析函数

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in education →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.