擅长:python、mysql、java
<p><a href="http://babel.pocoo.org/" rel="nofollow">^{<cd1>} module</a>允许接近所需的输出:</p>
<pre><code>from babel.dates import format_timedelta # $ pip install babel
print(", ".join(format_timedelta(timedelta(**{unit: fields[unit]}),
granularity=unit.rstrip('s'),
threshold=fields[unit] + 1,
locale='fr')
for unit in "hours minutes seconds".split()))
# -> 93 heures, 45 minutes, 40 secondes
</code></pre>
<p>它自动处理语言环境和复数形式,例如,<code>dur = timedelta(seconds=1)</code>它产生:</p>
^{pr2}$
<p>也许更好的解决方案是使用标准工具(如<code>gettext</code>)手动转换格式字符串。在</p>