python获取时间日期今天明天昨天前天
python获取今天明天昨天前天,或者30天后180天后1000天后的日期,也可获取30天前180天前1000天前的日期
·
安装datedays:
pip install datedays
代码:
import datedays
if __name__ == '__main__':
print("现在时间:", datedays.getnow()) # format_=格式,比如:%Y-%m-%d %H:%M:%S
print('-' * 30)
print("明天:", datedays.gettomorrow())
print("后天:", datedays.gettomorrow(days=2)) # days等于多少,就是多少天
print("30天后是几号:", datedays.gettomorrow(days=30))
print("180天后是几月几号:", datedays.gettomorrow(days=180))
print("1000天后是几月几号:", datedays.gettomorrow(days=1000))
print('-' * 30)
print("昨天:", datedays.getyesterday())
print("前天:", datedays.getyesterday(days=2))
print("180天前:", datedays.getyesterday(days=180))
print("1000天前是几月几号:", datedays.getyesterday(days=1000))
结果:
更多推荐
已为社区贡献2条内容
所有评论(0)