成语大全网 - 汉语词典 - python编写月份词典

python编写月份词典

import datetime

def find_date(t):

lis = []

while True:

n = int(input("请输入 n(2<=n<=8):"))

if n <= 8 and n >= 2:

break

d = datetime.datetime.now()

while t > 0:

if len(set(d.strftime('%Y-%m-%d'))) == n + 1:

lis.append(d.strftime('%Y-%m-%d'))

t -= 1

d += datetime.timedelta(days=1)

return lis

if __name__ == '__main__':

res = find_date(5)

for i in res:

print(i)

支持输出任意个满足要求的日期!

运行结果: