当前位置:首页 > Python > 正文内容

python获取昨天的日期

lonely2年前 (2022-09-28)Python820
import datetime
def getYesterday():
    today = datetime.date.today()
    oneday = datetime.timedelta(days=1)
    yesterday = today - oneday
    return yesterday
print(getYesterday())

运行结果:

2021-12-20


扫描二维码推送至手机访问。

版权声明:本文由复制者发布,如需转载请注明出处。

本文链接:https://www.copyer.cn/post/27.html

分享给朋友:

相关文章

启动Robot Framework时,运行ride.py报错:wx._core.wxAssertionError: C++ assertion "strcmp(setlocale(LC_ALL, NU

启动Robot Framework时,运行ride.py报错:wx._core.wxAssertionError: C++ assertion "strcmp(setlocale(LC_ALL, NU

进入Python目录下\lib\site-packages\robotide\application\目录,打开application.py文件在第50行,将self._initial_locale...

locustio安装失败,提示: ERROR: Command errored out with exit status 1:

locustio安装失败,提示: ERROR: Command errored out with exit status 1:

使用pip install locustio 和 pip install -i https://pypi.douban.com/simple locustio 安装时均失败,提示:C:\Us...

python-selenium设置webdriver隐藏浏览器运行及不加载图片

python-selenium设置webdriver隐藏浏览器运行及不加载图片

from selenium import webdriver # 设置无界面 opt = webdriver.ChromeOpt...

详解python的xlwings库读写excel操作总结

详解python的xlwings库读写excel操作总结

 一、总结一句话总结:xlwings 是 Python 中操作Excel的一个第三方库,支持.xls读写,.xlsx读写,操作非常简单,功能也很强大1、xlwings 中的逻辑:应用->...

python使用国内镜像源安装更新模块

python使用国内镜像源安装更新模块

由于python更新源速度较慢,且经常更新失败。国内更新源可秒更,以下是配置方法。1、python2.7更新pip命令1python -m pip install --upgrad...

Python pip更换安装源

Python pip更换安装源

常见的镜像源:华为:https://repo.huaweicloud.com/repository/pypi/simple 清华:https://pypi.tuna.tsinghua.edu...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。