def print_db():
con = lite.connect('master.db')
print ('Enter a first name:')
firstname = input('> ')
with con:
cur = con.cursor()
data = cur.fetchone()
cur.execute("SELECT * FROM Contacts WHERE First = (?);", (firstname,))
list_title = ['First Name', 'Last Name', 'Phone', 'Email']
k = 0
for i in cur:
print ("\n")
for j in i:
print (list_title[k],)
print (j)
if k < 5: k+=1
else:
k = 0
print (data)
print ('Enter 1 to return to main menu')
userinput = input('> ')
if userinput == "1":
main()
else:
main()
回溯列表索引在打印时超出范围 (list_title)[k],)
好的更新,所以你可以看到整个功能。