下面是我收到的输出,下面是我的代码。为什么我得到这个内存参考有什么原因?顺便说一句 - 缩进在我的程序中是正确的,但我很难在 stackoverflow 中发布它
>>>Welcome to the Main Menu, Richard.
>>>Please select from the following options:
>>>(1)Punch In
>>>(2)Punch Out
>>>(3)Exit
>>>(type 1, 2, or 3)
>>><__main__.PunchCard instance at 0x7f5c2b799ea8>
和代码
import xlrd
import sys
data = xlrd.open_workbook('data.xls')
sheetname = data.sheet_names()
employee_sheet = data.sheet_by_index(0)
uid_list = [c.value for c in employee_sheet.col(0)]
last_list = [c.value for c in employee_sheet.col(1)]
first_list = [c.value for c in employee_sheet.col(2)]
username_list = [c.value for c in employee_sheet.col(3)]
password_list = [c.value for c in employee_sheet.col(4)]
class PunchCard:
def idle_screen(self):
sys.stderr.write("\x1b[2J\x1b[H")
print "Press Enter to start PunchClock"
raw_input()
return self.user_login()
def user_login(self):
sys.stderr.write("\x1b[2J\x1b[H")
userinput = raw_input("Please enter your username.\n> ")
if userinput in username_list:
user_index = username_list.index(userinput)
self.user_first = first_list[user_index]
user_password = raw_input("Welcome %s, please enter your password.\n> " % self.user_first)
else:
print "That is an incorrect username."
raw_input("Press enter to re-enter your username.")
return self.user_login()
if user_password == password_list[user_index]:
return self.main_menu()
else:
sys.stderr.write("\x1b[2J\x1b[H")
print "You have entered an incorrect password.\nPress enter to try again, or type QUIT to return to previous menu."
raw_input()
return self.user_login()
def main_menu(self):
sys.stderr.write("\x1b[2J\x1b[H")
print "Welcome to the Main Menu, %s.\nPlease select from the following options:\n (1)Punch In\n (2)Punch Out\n (3)Exit\n\n(type 1, 2, or 3)" % self.user_first
menu_input = raw_input(self)
if menu_input == '1':
print "punched in"
raw_input("You clocked in at XX. Press enter to continue.")
return self.main_menu()
elif menu_input == '2':
print "punched out"
raw_input("You clocked out at XX. Press enter to continue.")
return self.main_menu()
elif menu_input == '3':
return self.idle_screen()
else:
return self.main_menu()
s = PunchCard()
s.idle_screen()