This action will force synchronization from Yonja/python100, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
#!/usr/bin/python# -*- coding: UTF-8 -*-import datetime"""题目:输出指定格式的日期。程序分析:使用 datetime 模块。datetime:datetime是date与time的结合体,包括date与time的所有信息。它的构造函数如下:datetime. datetime (year, month, day[ , hour[ , minute[ , second[ , microsecond[ , tzinfo] ] ] ] ] )各参数的含义与date、time的构造函数中的一样,要注意参数值的范围。"""if __name__=='__main__':#输出今日日期,格式为dd/mm/yyyyprint(datetime.date.today().strftime('%d/%m/%Y'))#创建日期对象myBirthDate = datetime.date(1941,1,5)print(myBirthDate.strftime('%d/%m/%Y'))#日期算术运算,timedelta表示时间间隔,+表示时间前进,-表示后退myBirthDate = myBirthDate + datetime.timedelta(days=1)print(myBirthDate.strftime('%d/%m/%Y'))#日期替换myBirthDate = myBirthDate.replace(year=myBirthDate.year + 1)print(myBirthDate.strftime('%d/%m/%Y'))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。