Pyhon DateTime的模块如何在相关类方法中的整理

开发 后端
如果你对Pyhon DateTime的模块的实际应用的过程中会遇到一些不解之处时,你就可以浏览以下的文章对其进行一个了解。

以下的文章就是对Pyhon DateTime的模块在实际应用过程中的具体介绍,本文涉及到的Pyhon DateTime相关的类方法整理,以及其相应的代码详解,希望你在看完我们的文章会有所收获。

 

相关联的模块还有time与calendar 其中的time我们上面已经做了整理。呆会再整理下日历相比time模块来讲的话这个模块在运算上更加方便一点。现在整理一下其帮助文档上面的内容出来

构造方法:

 

  1. datetime(year,month,day,[hour[,minute[,
    second[,microsecond[,tzinfo]]]]]) 

 

参数说明:

 

  1. <!--[if !supportLists]-->· <!--[endif]-->MINYEAR
     
    <= year <= MAXYEAR   
  2. <!--[if !supportLists]-->· <!--[endif]--><= month
     
    <= 12   
  3. <!--[if !supportLists]-->· <!--[endif]--><= day
     
    <= number of days in the given month and year   
  4. <!--[if !supportLists]-->· <!--[endif]-->
    <= hour < 24   
  5. <!--[if !supportLists]-->· <!--[endif]-->0
     
    <= minute < 60   
  6. <!--[if !supportLists]-->· <!--[endif]-->
    <= second < 60   
  7. <!--[if !supportLists]-->· <!--[endif]-->
    <= microsecond < 1000000   

 

Pyhon DateTime相关类方法整理

1、today() 返回当前的本地时间值

 

  1. if __name__ == '__main__':  
  2. datetimedatetimes = datetime.datetime(2001,12,2)  
  3.  

 

构造方法参数要指明正确哦

 

  1. print datetimes.today() 

 

返回:

  1. 2010-03-04 14:40:51.783000  

即为当前的时间值了

2、

  1. now([tz]) 

 

示例:

 

  1. if __name__ == '__main__':  
  2. datetimedatetimes = datetime.datetime(2001,12,2)  
  3. print datetimes.now()  

 

输出:

  1. 2010-03-04 14:43:09.127000 

 

如果没指定参数即表示当前的时间值!以上的文章就是对Pyhon DateTime的相关实际应用方案的部分介绍。

【编辑推荐】

  1. Python环境的实际应用方案介绍与代码详解
  2. 用python pylint检查相关东西的操作方案详解
  3. Python数据结构创建的具体应用方案详解
  4. Python语法的基本概念的阐述
  5. Python编程语言的实现内幕的相关介绍
责任编辑:佚名 来源: 博客园
相关推荐

2010-03-18 12:19:03

Pyhon DateT

2023-12-22 08:38:02

Pythondatetimetime

2010-03-22 11:07:18

Python常用模块I

2022-06-23 08:00:53

PythonDateTime模块

2015-09-28 10:12:21

Linux磁盘碎片

2015-09-25 15:57:09

磁盘碎片整理Linux

2010-03-19 13:04:12

Pyhon脚本解释器

2010-05-19 18:29:53

整理MySQL

2010-04-12 11:19:47

编译内核模块

2009-06-17 13:19:50

Java调用DLL

2010-03-31 18:38:10

Oracle命令

2010-03-18 14:16:52

Java Thread

2022-10-31 08:24:24

UbuntuLinux

2010-03-18 12:40:47

python正则表达式

2023-06-05 16:41:27

Python开发

2019-04-23 15:20:26

JavaScript对象前端

2020-06-29 07:52:17

Java工具类开发

2010-07-20 09:13:55

Perl面向对象编程

2023-01-29 08:00:00

Instagram滤镜图片编辑

2010-03-19 11:04:20

python模块
点赞
收藏

51CTO技术栈公众号