王喜兴喝橙汁 2019-07-12 21:36 采纳率: 0%
浏览 462

在LunarDate.from_solar_date中使用数组中的日期

from borax.calendars.lunardate import LunarDate
df=['1990,1,1','1990,1,2','1990,1,3']
ld = LunarDate.from_solar_date(df[2])
ld

运行之后错误提示是:
TypeError Traceback (most recent call last)
in
1 from borax.calendars.lunardate import LunarDate
2 df=['1990,1,1','1990,1,2','1990,1,3']
----> 3 ld = LunarDate.from_solar_date(df[2])
4 ld

TypeError: from_solar_date() missing 2 required positional arguments: 'month' and 'day'

因为引用df[2]的时候是'1990,1,3',而不是1990,1,3,那么怎么使用可以正确呢?

  • 写回答

1条回答 默认 最新

  • threenewbee 2019-07-12 22:18
    关注

    s = df[2]
    s.split(",")
    yy = int(s[0])
    mm = int(s[1])
    dd = int(s[2])
    ld = LunarDate.from_solar_date(yy,mm,dd)

    评论

报告相同问题?