1. 程式人生 > >python輸入年份與該年中的第幾天,得出這天是該年的幾月幾日?

python輸入年份與該年中的第幾天,得出這天是該年的幾月幾日?

python3版本

import datetime

def get_date(num1,num2):

    now_time = datetime.datetime(num1, int('01'), int('01'))

    f = now_time + datetime.timedelta(days=num2-1)

    fu = f.strftime('%Y%m%d')

    print(fu)

get_date(2012,60)