当前位置: 首页 > 图灵资讯 > 行业资讯> python time.ctime()如何做时间加减法

python time.ctime()如何做时间加减法

发布时间:2024-07-25 20:18:44

1、语法

time.ctime([sec])

2、参数,sec,转换为字符串时间的秒数。

3、时间加减法需要用秒代替所有加减参数。

实例

importtime
#获取当前时间
print(time.ctime())
#获取当前时间
later=time.time()+86400
#计算一天后的时间
print(time.ctime(later))
#计算20秒后的时间
print(time.ctime(time.time()+20))

以上是python time.ctime()做时间加减法,希望对大家有所帮助。更多Python学习指导:基础教程python基础教程

本文教程操作环境:windows7系统Python 3.9.1,DELL G3电脑。

相关文章

python3兼容python2吗

python3兼容python2吗

2025-05-09
python3 whl怎么安装

python3 whl怎么安装

2025-05-09
python 字典怎么提取value

python 字典怎么提取value

2025-05-09
python 怎样计算字符串的长度

python 怎样计算字符串的长度

2025-05-09
python 怎么样反向输出字符串

python 怎么样反向输出字符串

2025-05-09
python 怎么判断字符串开头

python 怎么判断字符串开头

2025-05-09