• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > python获取当前日期和时间的方法

python获取当前日期和时间的方法

作者: 字体:[增加 减小] 来源:互联网

通过本文主要向大家介绍了python获取当前日期,python 获得当前日期,python 当前日期,python 获取当天日期,python 获取日期等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

本文实例讲述了python获取当前日期和时间的方法。分享给大家供大家参考。具体如下:

import datetime
# Get a datetime object
now = datetime.datetime.now()
# General functions 
print "Year: %d" % now.year
print "Month: %d" % now.month
print "Day: %d" % now.day
print "Weekday: %d" % now.weekday()
# Day of week Monday = 0, Sunday = 6
print "Hour: %d" % now.hour
print "Minute: %d" % now.minute
print "Second: %d" % now.second
print "Microsecond: %d" % now.microsecond
# ISO Functions
print "ISO Weekday: %d" % now.isoweekday()
# Day of week Monday = 1, Sunday = 7
print "ISO Format: %s" % now.isoformat()
# ISO format, e.g. 2010-12-24T07:10:52.458593
print "ISO Calendar: %s" % str(now.isocalendar())
# Tuple of (ISO year, ISO week number, ISO weekday)
# Formatted date
print now.strftime("%Y/%m/%d")
</div>

希望本文所述对大家的Python程序设计有所帮助。

</div>

您可能想查找下面的文章:

  • Python实现文件按照日期命名的方法
  • 在Python中处理日期和时间的基本知识点整理汇总
  • python返回昨天日期的方法
  • python获取当前日期和时间的方法
  • python获取当前日期和时间的方法
  • python实现根据月份和日期得到星座的方法
  • python实现根据月份和日期得到星座的方法

相关文章

  • python3访问sina首页中文的处理方法
  • Python中正则表达式的详细教程
  • Python数据类型详解(一)字符串
  • 详解Python中 __get__和__getattr__和__getattribute__的区别
  • Python3的urllib.parse常用函数小结(urlencode,quote,quote_plus,unquote,unquote_plus等)
  • python中安装模块包版本冲突问题的解决
  • Python中用Descriptor实现类级属性(Property)详解
  • Python中用Ctrl+C终止多线程程序的问题解决
  • Python自定义进程池实例分析【生产者、消费者模型问题】
  • Django小白教程之Django用户注册与登录

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • python文件和目录操作函数小结
    • python创建线程示例
    • 推荐下python/ironpython:从入门到精通
    • 在Python3中初学者应会的一些基本的提升效率的小技巧
    • python3模拟百度登录并实现百度贴吧签到示例分享(百度贴吧自动签到)
    • python client使用http post 到server端的代码
    • python处理中文编码和判断编码示例
    • python实现从字典中删除元素的方法
    • jupyter安装小结
    • python通过装饰器检查函数参数数据类型的方法

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有