我试图找到两个日期之间的天数,并将其输出为字符串。你知道吗
这是我的东西
currentDate = datetime.datetime.now()
newDate = currentDate + datetime.timedelta(days=3)
dateDifference = newDate - currentDate
print(dateDifference)
我试过了
print(dateDifference.strftime('%d'))
但这行不通。你知道吗
我只想把数字“3”说成一个字符串。你知道吗
谢谢。你知道吗
输出
为什么不:
或者如果你想要一个字符串,你可以做下面的代码,按照@BenT所采取的解决方案使用
str
,这是首选的(你应该使用这个),我会给出一个字符串格式的解决方案:如果你想把日差作为一个字符串,你可以这样做
相关问题 更多 >
编程相关推荐