Get Day name from Weekday int

后端 未结 8 1137
梦如初夏
梦如初夏 2020-12-14 05:14

I have a weekday integer (0,1,2...) and I need to get the day name (\'Monday\', \'Tuesday\',...).

Is there a built in Python function or way of doing this?

H

8条回答
  •  清歌不尽
    2020-12-14 06:14

    You can create your own list and use it with format.

    import datetime
    
    days_ES = ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"]
    
    t = datetime.datetime.now()
    f = t.strftime("{%w} %Y-%m-%d").format(*days_ES)
    
    print(f)
    

    Prints:

    Lunes 2018-03-12
    

提交回复
热议问题