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

python获取昨天的日期

lonely2年前 (2022-09-28)Python713
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

分享给朋友:

相关文章

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 pip更换安装源

Python pip更换安装源

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

windows更换conda源

windows更换conda源

使用清华源一、cmd中执行conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/an...

windows中配置conda环境变量

windows中配置conda环境变量

一、下载(根据自己的电脑系统下载对应的安装包)官方下载地址:https://www.anaconda.com/products/distribution二、安装下载后双击安装包安装,可以一直下一步默认...

发表评论

访客

看不清,换一张

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