Post

Daily Python Tip 🐍🐧
Daily Python Tip 🐍🐧@python_tip·
#python_tip from @NurmeAve: Python's divmod() is one way to convert months into years and months: divmod(1, 12) # (0, 1) -> 0 years & 1 month divmod(12, 12) # (1, 0) -> 1 year & 0 months divmod(55, 12) # (4, 7) -> 4 years & 7 months
English
1
10
46
0
malo21st
malo21st@malo21st·
@python_tip @NurmeAve #Python メモ divmod(割られる数, 割る数) で商と余りのタプルが返ってくる。 年月に分けるやり方もあるけど、 m×nの長さのリストLがあって、 divmod(x, n) ただし、0≦x≦m×n m行n列の2次元配列Dがあると D[divmod(x, n)[0]][divmod(x, n)[1]] で、1次元Lで2次元Dが表現できる
malo21st tweet media
日本語
1
0
0
0
Paylaş