java的list没有get,“AttributeError:'list' object没有属性'get'”

在这里,我试图将英语日期转换为相当的尼泊尔日期 . 当我运行代码时,我得到“AttributeError:'list'对象没有属性'get'”作为错误 . 以下是我的代码 .

from datetime import date

import datetime

import time

import calendar

engMonth=int(input('Enter birth month in A.D.'))

engDate=int(input('Enter birth date in A.D.'))

engYear=int(input('Enter birth year in A.D.'))

下面是没有列表 . 每年每个月的有效范围内的天数

尼泊尔年月份列表,其中,2000年,2001年,2002年等是尼泊尔年份,30,32,31等是以月为单位的总天数

nepaliMonths = [

[ 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ], #2000

[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ], #2001

[ 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],

[ 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ],

[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],

[ 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31 ],

[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],

[ 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30 ],

[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],

[ 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30 ],

[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ],

[ 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ],

[ 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],

[ 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ],

[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],

[ 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ],

[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],

[ 30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31 ],

[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],

[ 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30 ],

[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],

[ 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30 ],

[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],

[ 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ],

[ 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ],

[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],

[ 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ],

[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],

[ 30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31 ],

[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],

[ 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31 ],

[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ],

[ 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30 ],

[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ], #2071

[ 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30 ], #2072

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31 ], #2073

[ 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31 ],

[ 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30 ],

[ 31, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30 ],

[ 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30 ],

[ 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30 ],

[ 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30 ],

[ 31, 32, 31, 32, 30, 31, 30, 30, 29, 30, 30, 30 ],

[ 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30 ],

[ 31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30 ],

[ 30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30 ],

[ 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30 ],

[ 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30 ], #2090

[ 31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30 ],

[ 30, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30 ],

[ 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30 ],

[ 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30 ],

[ 31, 31, 32, 31, 31, 31, 30, 29, 30, 30, 30, 30 ],

[ 30, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30 ],

[ 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30 ],

[ 31, 31, 32, 31, 31, 31, 29, 30, 29, 30, 29, 31 ],

[ 31, 31, 32, 31, 31, 31, 30, 29, 29, 30, 30, 30 ] #2099

]

#define the least possible English date 1944/01/01 Saturday.

startingEngYear = 1944

startingEngMonth = 1

startingEngDay = 1

dayOfWeek = calendar.SATURDAY #1944 is a saturday

#Let's define the equivalent Nepali date 2000/09/17.

startingNepYear = 2000

startingNepMonth = 9

startingNepday = 17

# Let's calculate the number of days between the two English dates as follows:

date0=date(engYear,engMonth,engDate)

date1=date(startingEngYear,startingEngMonth,startingEngDay)

delta=date0 - date1

# print (delta.days)

#initialize required nepali date variables with starting nepali date

nepYear = startingNepYear

nepMonth = startingNepMonth

nepDay = startingNepday

错误在此代码块中 .

# decreament delta.days until its value becomes zero

while delta.days != 0:

# getting total number of days in month nepMonth in a year nepYear

daysInMonth = nepaliMonths.get(nepYear)[nepMonth]

nepDay+=1 # incrementing nepali day

if(nepDay > daysInMonth):

nepMonth+=1

nepDay = 1

if(nepMonth > 12):

nepYear+=1

nepMonth = 1

dayOfWeek+=1 #counting the days in terms of 7 days

if(dayOfWeek > 7):

dayOfWeek = 1

delta.days-=1

救命

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值