In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Environment: Python 2.7
can further improve
# -*- coding: utf-8-*-print u"+===================================================+"print u"+======================================== = "C:\Users\95112\Desktop\ATM\goods" #Define the location of the goods list salary = 0#Login def login(): global a global salary username=[] password=[] money =[] f = file(user_name) for line in f.readlines(): new_line = line.split() username.append(int(new_line[0])) password.append(int(new_line[1])) money.append(int(new_line[2])) UserName = int(raw_input("please input your username:")) if UserName in username: PassWord = int(raw_input("please input your password:")) username_passwd = password[username.index(UserName)] #Remove password corresponding to username salary = money[username.index(UserName)] #Remove money from your account if PassWord == username_passwd: a = 1 #Sign of successful login print "Login successful" print "You still have %s of the balance" % money else: a = 0 print "password error" else: a = 0 print "your username error" return a return salary#def shopping(): global salary products=[] price=[] shop_list= [] f = file(goods) for line in f.readlines(): new_line = line.split() products.append(new_line[0]) price.append(int(new_line[1])) while 1: print u'Please choose one or more of the following items to buy: print products for i in range(0,len(products)): if (salary>=price[i]): print products[i],price[i] print "+---------------------------------+" print u"Enter exit to exit the purchase" choice = raw_input("please choice a shop to buy:") F_choice = choice.strip()#Strips spaces and formats output. #exit loop if F_choice == "exit": break if F_choice in products: product_price = price[products.index(F_choice)] #Take out product price print "+---------------------------------+" print u"The item you want to buy and the price: ",F_choice,product_price print u"Item is being added to shopping list, please wait" if salary > product_price: shop_list.append(F_choice) salary = salary - product_price print "+---------------------------------+" print u"You have successfully purchased %s" % F_choice print u"Your balance is still: ", salary print u"The items you have purchased are: ", shop_list print "+---------------------------------+" else: pass else: print u"The product you entered is not in the product list, please re-enter! " def Transfer_accounts(): global salary print u"There is a 5% service charge for each transfer and withdrawal. " inputs = int(raw_input("please input you should how much money:")) SS = inputs*0.05 zong = inputs + SS if ( salary < zong or salary < inputs): print u"Insufficient balance" else: salary = salary - zong print "+------------------------------+" print u"successful transfer %s" % inputs print u"Deduct commission %s" % SS print "+------------------------------+" def check_the_balance(): global salary print "+---------------------------+" print u"You have %s" % salary print "+---------------------------+"#Menu def menu(): print u"""Welcome to use ATM automatic teller machine If the machine failure please contact ATM\t """ while True: print u"\t(1) Shopping" print u"\t(2) Transfer" print u"\t(3) Query Balance" print u"\t(4) Exit" choices = raw_input("Please choices:").strip() if len(choices) == 0: continue if choices == '1': shopping() elif choices == '2': Transfer_accounts() elif choices == '3': check_the_balance() else: print "Please pay attention to the property security" exit()if __name__ == '__main__': login() if a == 1: menu() else: pass
Run Results:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.