Python datetime.timestamp 参考
Python datetime.timestamp 参考,整理标准库调用语法、参数、示例、返回值和常见错误。
语法
from datetime import datetime
seconds = datetime.now().timestamp()
参数
value:日期时间字符串、时间戳或 datetime/date 对象。format / tzinfo:解析格式或时区设置。
返回值
返回 datetime/date/timedelta 对象、时间戳或格式化字符串。
示例
from datetime import datetime
print(datetime.now().timestamp())
常见错误
- 解析格式和输入字符串不一致会抛出 ValueError。
- 混用有时区和无时区时间会导致比较或计算报错。
相关内容
相关内容
- Python collections.ChainMap 参考 Python collections.ChainMap 参考,整理标准库调用语法、参数、示例、返回值和常见错误。
- Python collections.Counter 参考 Python collections.Counter 参考,整理标准库调用语法、参数、示例、返回值和常见错误。
- Python collections.defaultdict 参考 Python collections.defaultdict 参考,整理标准库调用语法、参数、示例、返回值和常见错误。
- Python collections.deque 参考 Python collections.deque 参考,整理标准库调用语法、参数、示例、返回值和常见错误。
- Python collections.most_common 参考 Python collections.most_common 参考,整理标准库调用语法、参数、示例、返回值和常见错误。
- Python collections.namedtuple 参考 Python collections.namedtuple 参考,整理标准库调用语法、参数、示例、返回值和常见错误。