Import Collectionsdef login ():li=[' Xiaohei ', ' 123456 ', ' Xiaohuang ', ' 23456 ', ' Xiaoli ', ' 34567 ']dic={}C=0While True:For I in range (Len (LI)):if (i+1)%2==1:Dic[str (Li[i])]=str (li[i+1])ElsePassprint ' Welcome to the shopping system! ‘User=raw_input ("Please enter your user name:")If user in Dic.keys ():While cC+=1Passwd=raw_input ("Please enter your password:")If dic[user]==passwd:print ' Welcome to login! ‘ReturnElseprint ' Password is w
Functional Requirements:Require users to enter total assets, for example: 2000Display the list of items, let the user select the item according to the serial number, add the shopping cartPurchase, if the total amount of goods is greater than the total assets, indicating that the account balance is insufficient, otherwise, the purchase succeeds.Add: Can recharge, a product to remove the shopping cartgoods =
-dimensional list becomes a two-dimensional list, the two list changes at the same timeThis is a shallow copy, cloning only the first layer listThe second list is a reference to the first listBased on the shallow copy, modify the copy out of the list, you can implement the concept of similar inheritanceDeep copyImport CopyCopy.copy (a_list): shallow copy, same as A_list.copy ()Copy.deepcopy (a_list): Deep copyDon't use it. Large amount of data memory consumptionTwo-dimensional listEach element i
1 #!/usr/bin/python2 #Coding=utf-83 ImportMultiprocessing4 5Str="Welcome to the rookie shopping system! "6 PrintStr.center (80)7Money=input ("Please enter your budget:",)8 defShow ():9 Print " "This shop offers the following products:Ten Kindle One mac A Apple $450 - mp3 - ThinkPad $800" " the Show () -d={'Kindle': 300,'mac': 500,'mp3': 30,'ThinkPad': 800,'Apple': 450} - - defShop (Money): +d1={} - forIinchD: + ifMoney>D[i]: Ad1[i]=
not exit_flag: # 2nd loop for City in China[choice_province]: Print (city) print () choice_city = input ("2. Please enter the urban area you want to go to (Enter Q exit, enter B to return to the superior):") pri NT () if ChoicE_city = = "Q": Exit_flag = True elif choice_city = = "B": Break # jumps out of the 2nd loop, re- 1-Layer Loop (select province) elif choice_city in china[choice_province]: And not exit_flag: # 3rd Loop For county in china[choice_prov
=dict () forLineinchUse:line=line.strip (). Split (' ') Dic[line[0]]=line[1:]use.close () name=input ('Please enter user name:') Flag1=True whileFlag1: forKeyinchDIC:ifkey==Name:password=input ('Please enter your password:') ifpassword==Dic[key][0]:Print('your current balance is%s, you have purchased the following items:%s'% (dic[key][1],dic[key][2:])) Print('the list of items available for purchase is as follows:') forIndex,itemsinchEnumerate (pro_list):Print(index+1,
Python program Exercise 3 -- simulate a shopping cart, python3 --1. Features
This program simulates the user's purchase of goods after logging on to the mall. Allows users to log on, purchase commodities, query historical consumption records, and update balances and consumption information. Enter the initial account funds for the first login, and then log on to t
This article mainly introduces how to use the Python Django framework and jQuery to implement the AJAX shopping cart page. For example, if you need RESTfulAPI in JSON format built in Django, refer
Integrate jquery in DjangoFirst, static resources are usually put in the static Folder:
static/ css/ djquery.css samples/ hello.css js/ jquery-1.7.1.
This article mainly introduces how to use the Python Django framework and jQuery to implement the AJAX shopping cart page. for example, if you need RESTfulAPI in JSON format built in Django, refer
Integrate jquery in DjangoFirst, static resources are usually put in the static folder:
static/ css/ djquery.css samples/ hello.css js/ jquery-1.7.1.
Product_list = [("Iphone", 6000),("Mac Pro", 12800),("Bike", 600),("Watch", 8000),("book", 24),("Offee", 35),]Shopping_list = ()Salary = (Input ("Please enter your purchase:"))If Salary.isdigit (): # To determine if the value entered is numeric, then continuesalary = Int (salary)While True:For item in Product_list:Print (Product_list.index (item), item) # Prints the list's subscript and listUser_choice = input ("Please enter the item number you want to purchase:")If User_choice.isdigit ():user_c
: // 172.16.1.20./ csrfYohu.html to start automatically traversing the shopping cart content of Account B.
Shopping Cart before deletion
After running for half a minute, I found that one shopping cart was missing! @@!
Csrf atta
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.