Python timedelta total_seconds()方法与示例
Python timedelta.total_seconds()方法 (Python timedelta.total_seconds() Method)
timedelta.timedeltotal_seconds() method is used in the timedelta class of module datetime.
timedelta.timedeltotal_seconds()方法在模块datetime的timedelta类中使用。
It uses an instance of the class and returns the total number of seconds covered in the given duration of that time instance.
它使用该类的实例,并返回在该时间实例的给定持续时间内覆盖的总秒数。
Module:
模块:
import datetime
Class:
类:
from datetime import timedelta
Syntax:
句法:
total_seconds()
Parameter(s):
参数:
None
没有
Return value:
返回值:
The return type of this method is a number which is the total number of seconds covered in that period.
此方法的返回类型是一个数字,该数字是该时间段内覆盖的总秒数。
Example:
例:
## Python program to illustrate
## the use of total_seconds function
from datetime import time, timedelta
## total_seconds function
x = timedelta(minutes = 2*15)
total = x.total_seconds()
print("Total seconds in 30 minutes:", total)
print()
## time can be negative also
x = timedelta(minutes = -2*15)
total = x.total_seconds()
print("Total seconds:", total)
print()
x = timedelta(days = 1, minutes = 50, seconds = 56)
total = x.total_seconds()
print("Total seconds in the given duration:", total)
print()
x = timedelta(hours=1,minutes= 50,seconds= 40)
y = timedelta(hours=10,minutes= 20,seconds= 39)
d = y-x
print("Total seconds covered in subtracting:", d.total_seconds())
print()
x = timedelta(hours=1,minutes= 50,seconds= 40)
y = timedelta(hours=10,minutes= 20,seconds= 39)
d = y+x
print("Total seconds covered in adding:", d.total_seconds())
print()
x = timedelta(hours=1,minutes= 50,seconds= 40)
y = timedelta(hours=10,minutes= 20,seconds= 39)
d = y%x
print("Total seconds remaining when y is divided by x", d.total_seconds())
print()
Output
输出量
Total seconds in 30 minutes: 1800.0
Total seconds: -1800.0
Total seconds in the given duration: 89456.0
Total seconds covered in subtracting: 30599.0
Total seconds covered in adding: 43879.0
Total seconds remaining when y is divided by x 4039.0
翻译自: https://www.includehelp.com/python/timedelta-total_seconds-method-with-example.aspx
Python timedelta total_seconds()方法与示例相关推荐
- python forward(10)什么意思-Python turtle.forward方法代码示例
本文整理汇总了Python中turtle.forward方法的典型用法代码示例.如果您正苦于以下问题:Python turtle.forward方法的具体用法?Python turtle.forwar ...
- Python cv2.minMaxLoc方法代码示例
本文整理汇总了Python中cv2.minMaxLoc方法的典型用法代码示例.如果您正苦于以下问题:Python cv2.minMaxLoc方法的具体用法?Python cv2.minMaxLoc怎么 ...
- msvcrt python linux,Python msvcrt.CrtSetReportMode方法代码示例
# 需要导入模块: import msvcrt [as 别名] # 或者: from msvcrt import CrtSetReportMode [as 别名] def __enter__(self ...
- archlm检验python,Python sublime.arch方法代码示例
# 需要导入模块: import sublime [as 别名] # 或者: from sublime import arch [as 别名] def run(self): info = {} inf ...
- python dateformatter_Python dates.DateFormatter方法代码示例
本文整理汇总了Python中matplotlib.dates.DateFormatter方法的典型用法代码示例.如果您正苦于以下问题:Python dates.DateFormatter方法的具体用法 ...
- python2.7使用TimeDelta中total_seconds()方法的问题
运维过程中经常在做日期相加减时使用TimeDelta对象,python2.7及以后的TimeDelta有total_seconds()方法获取总秒数,而2.6之前没有该方法,且众所周知大多数非pyth ...
- python中weekday_Python calendar.weekday方法代码示例
本文整理汇总了Python中calendar.weekday方法的典型用法代码示例.如果您正苦于以下问题:Python calendar.weekday方法的具体用法?Python calendar. ...
- g的python实现_Python flask.g方法代码示例
本文整理汇总了Python中flask.g方法的典型用法代码示例.如果您正苦于以下问题:Python flask.g方法的具体用法?Python flask.g怎么用?Python flask.g使用 ...
- doc python 颜色_Python wordcloud.ImageColorGenerator方法代码示例
本文整理汇总了Python中wordcloud.ImageColorGenerator方法的典型用法代码示例.如果您正苦于以下问题:Python wordcloud.ImageColorGenerat ...
最新文章
- php项目数据库连接设置,在PHP中设置数据库连接类
- thinkphp两表联查并且分页
- 母版页调用内容页的方法的简单实现
- C++学习笔记章节中 面向对象详解
- 杭电java期末试卷2015_2014年杭州电子科技大学Java期末试卷.doc
- Node单线程的特点
- linux 与win共享文件夹
- py-R-FCN安装
- HandBrake for Mac功能界面详解
- OpenCV入门知识[转载]
- Matlab下载 安装 与 和谐教程
- c语言中除号用百分号,【期末复习】人教版六年级数学(下册)知识要点
- 信息系统分析与设计(自考)
- java的GUI:个人所得税计算
- IT 开发常见 英文简称 VO, BO, PO的讲解
- Oracle的 wm_concat 的排序问题,Oracle的 listagg 函数
- 微软商店,打开就显示无法加载该页面 代码0x80131500,网上一般不说的标准解决方案
- 世间安得双全法,不负如来不负卿
- 华师大网络学院计算机,华师大网络学院计算机原理作业.doc
- PayPal/Stripe/Square轮询收单系统 stripe paymentlink支付模式
热门文章
- 电子工程可以报考二建_非工程类专业也能报考二建吗?
- hbase 页面访问_HBase
- 浙江大学计算机保研条件_【如何将保研成功率提至100%】来自取得浙大等五所顶尖院校保研资格学长的干货分享(联系导师章节已更)...
- iphone主屏幕动态壁纸_iPhone8怎么设置动态壁纸?iPhone8动态壁纸设置教程
- python嵌套列表操作_python基础(list列表的操作,公共方法,列表嵌套,元祖)...
- delphi 生成 超大量xml_用OpenCV4实现图像的超分别率
- ajax加载进度百分比,在ajax中显示加载百分比的进度条,php
- 缓存雪崩、击穿、穿透解决方案
- JDK源码解析之 java.lang.System
- 修改win10我的文档下载等移动别处