我会尽力完成翻译工作。以下是您需要翻译的内容:
我想找出两个日期之间的天数,并将其输出为字符串。
这是我现在有的:
currentDate = datetime.datetime.now()
newDate = currentDate + datetime.timedelta(days=3)
dateDifference = newDate - currentDate
print(dateDifference)
我尝试过
print(dateDifference.strftime('%d'))
但是这样不起作用。
我希望输出结果只显示数字"3",以字符串形式呈现。
谢谢。
string
函数。 - user2357112str
,不好意思,我把2.7和3.x搞反了。 - BenT