本文介紹了在python中用波蘭語(yǔ)中的月份名稱(chēng)格式化日期的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
在 python 中(或在 django 模板中)是否有一種開(kāi)箱即用的方式來(lái)格式化一個(gè)符合波蘭語(yǔ)規(guī)則的完整月份名稱(chēng)的日期?
Is there an out of the box way to format in python (or within django templates), a date with full month name in accordance to polish language rules?
我想得到:
6 wrze?nia 2010
而不是:
>>> datetime.today().date().strftime("%d %B %Y")
'06 wrzesień 2010'
推薦答案
使用 通天塔:
>>> import babel.dates
>>> import datetime
>>> now = datetime.datetime.now()
>>> print(babel.dates.format_date(now, 'd MMMM yyyy', locale='pl_PL'))
6 wrze?nia 2010
更新:納入 Nathan Davis 的評(píng)論.
Update: Incorporated Nathan Davis' comment.
這篇關(guān)于在python中用波蘭語(yǔ)中的月份名稱(chēng)格式化日期的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!