有人可以解释为什么我必须输入我的“名字”两次吗?另外,如果你有小费。如果循环找不到任何匹配项,我希望用户再次输入名称。
import xlrd
def open_file(path):
wb = xlrd.open_workbook(path)
sheet = wb.sheet_by_index(0)
while True:
name = input("name: ")
nbre_consulate = 1
for row_num in range(sheet.nrows):
row_value = sheet.row_values(row_num)
if row_value[0] == name and row_value[1] == nbre_consulate:
return int(row_value[2])
path = "imperator.xlsx"
open_file(path)
print(open_file(path))
在拥有我的row_value[3]. 我不明白为什么。
name: Spurius Lartius
name: Spurius Lartius
506
感谢您的任何提示!
三国纷争
相关分类