Python datetime isoweekday()方法与示例

news/2024/7/20 23:09:38 标签: python, java, django, 深度学习, ios

Python datetime.isoweekday()方法 (Python datetime.isoweekday() Method)

datetime.isoweekday() method is used to manipulate objects of datetime class of module datetime.

datetime.isoweekday()方法用于操作模块datetime的datetime类的对象。

It uses a datetime class object and returns the day of the week as an integer, where Monday is 1 and Sunday is 7. It is the same as datetime.weekday() function where we consider Monday is 0 incrementing by one for the coming days. It is an instance method as it works on an instance of the date class.

它使用datetime类对象并以整数形式返回星期几,其中Monday是1,Sunday是7。它与datetime.weekday()函数相同,在该函数中 ,我们认为星期一在接下来的几天中0递增1。 。 它是一个实例方法,因为它可用于date类的实例。

Module:

模块:

    import datetime

Class:

类:

    from datetime import datetime

Syntax:

句法:

    isoweekday()

Parameter(s):

参数:

  • None

    没有

Return value:

返回值:

The return type of this method is a number which tells us what is the day of the week on that day.

此方法的返回类型是一个数字,该数字告诉我们当天的星期几。

Example:

例:

## importing datetime class
from datetime import datetime

## Since we know the number, 
## we can save them in a list and 
## print the day on that number
day =["0","Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]

## Creating an instance
x = datetime.today() ## or use datetime.now()
d = x.isoweekday()
print("Today's isoweekday number is:", d)
print("Today's day is:",day[d])

x = datetime(2010, 1, 1)
print("Day on", x.year,"new year was:", day[x.isoweekday()])

x = datetime(2011, 1, 1)
print("Day on", x.year,"new year will be:", day[x.isoweekday()])

Output

输出量

Today's isoweekday number is: 5
Today's day is: Friday
Day on 2010 new year was: Friday
Day on 2011 new year will be: Saturday


翻译自: https://www.includehelp.com/python/datetime-isoweekday-method-with-example.aspx


http://www.niftyadmin.cn/n/1255442.html

相关文章

ES系列一、CentOS7安装ES 6.3.1、集成IK分词器

Elasticsearch 6.3.1 地址: wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.1.tar.gz 2.安装配置 1.拷贝 拷贝到服务器上,解压:tar -xvzf elasticsearch-6.3.1.tar.gz 。解压后路径:/home/elastic…

java timezone_Java TimeZone getRawOffset()方法与示例

java timezoneTimeZone类的getRawOffset()方法 (TimeZone Class getRawOffset() method) getRawOffset() method is available in java.util package. getRawOffset()方法在java.util包中可用。 getRawOffset() method is used to return the amount of time in milliseconds (…

Hexo页面优化和音乐的心得

灵感 这两天在添加“留言”以及“关于”页面,准备先简单设计一下自已的页面。留言页面可以放置一些自已比较感兴趣的音乐、以及一些JS特效,再集成一个第三方的留言功能。关于页面可以放置一些简单的联系方式、以及基础信息的存放,还有自已帅照…

threadgroup_Java ThreadGroup setDaemon()方法与示例

threadgroupThreadGroup类的setDaemon()方法 (ThreadGroup Class setDaemon() method) setDaemon() method is available in java.lang package. setDaemon()方法在java.lang包中可用。 setDaemon() method is used to set the daemon behavior of this thread group. As we kn…

Java语言环境getDisplayName()方法与示例

语言环境类getDisplayName()方法 (Locale Class getDisplayName() method) Syntax: 句法: public final String getDisplayName();public String getDisplayName(Locale lo);getDisplayName() method is available in java.util package. getDisplayName()方法在ja…

数据结构与算法-树与二叉树

数据结构与算法-树与二叉树 树的基本概念 根节点;边;分支节点;叶子节点;子树非空树有且仅有一个根节点.没有后继的节点称为叶子节点(或终端节点).有后继的节点称为分支节点(或非终端节点)除了根节点,任何一个节点都有且仅有一个前驱. 树的基本术语 关系描述 祖先节点子孙节…

Java IdentityHashMap clear()方法与示例

IdentityHashMap类clear()方法 (IdentityHashMap Class clear() method) clear() method is available in java.util package. clear()方法在java.util包中可用。 clear() method is used to remove all the existing entries from this IdentityHashMap . clear()方法用于从此…

seam的定时轮巡

青岛的项目要做一个功能,每天凌晨2点的时候保存一次设备数据,这个就要求项目能够间隔24小时每天去做这个事,是一个自主轮巡。 seam框架正好提供了这个功能,Expiration指定开始时间,IntervalDuration指定轮巡间隔毫秒数…