私のコードは以下の通りです:のpython3: "とValueError:int型のための無効なリテラル()ベース10と: '2.0'"
def MonthID(month):
"""INPUT:
'month' is the amount of months after the beginning of the computed rotation.
OUTPUT:
Returns the month ID composed by the 3 first letters of the month
name and the amount of years after the beginning of the rotation.
"""
year = str((month//12)+1)
if month % 12 == 0:
return "dec"+ str(int(year) - 1)
elif month % 12 == 1:
return "jan"+year
elif month % 12 == 2:
return "feb"+year
... など...ランダム
、ときyear
が1を超えると、私はこのエラーを受け取ります:ValueError: invalid literal for int() with base 10: '2.0'
。まあ、数字ではありません... ...
私はこれまで何の問題もなく、機能は正常に機能していました... 私の "12月のライン"を以下のように分解しようとしました。
year = int(year) - 1
return "dec"+ str(year)
他にこの種のエラーがありましたか? 関数が呼び出されたフレームから問題が発生することがありますが、私はそれを理解できません...私はprint
でこの関数を使用して、コードがどこにあるのかを簡単に知ることができます。