我遇到了以下错误:
这是代码:
currency = row[0]
IndexError: list index out of range
这是代码:
这是代码:
crntAmnt = int(input("Please enter the amount of money to convert: "))
print(currencies)
exRtFile = open ('exchangeRate.csv','r')
exchReader = csv.reader(exRtFile)
crntCurrency = input("Please enter the current currency: ")
validateloop=0
while validateloop == 0:
for row in exchReader:
currency = row[0]
if currency == crntCurrency:
crntRt = row[1]
validateloop=+1
以下是CSV文件:
日元,169.948
美元,1.67
英镑,1
欧元,5.5
以下是输入/输出示例:
Please enter the amount of money to convert: 100
['Pound Sterling', 'Euro', 'US Dollar', 'Japanese Yen']
Please enter the current currency: Pound Sterling
exchangeRate.csv
里面有什么内容... - A.J. Uppalrow
是否有第零个元素,或者它是否实际上是一个列表会很有用吗? - kindall