成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

python學(xué)習(xí)之登陸購物-創(chuàng)新互聯(lián)

#author:yangxiao
'''

成都創(chuàng)新互聯(lián)公司-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價比灌南網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式灌南網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋灌南地區(qū)。費用合理售后完善,十年實體公司更值得信賴。

購物車需求
用戶入口:
1.商品信息存在文件里
2.已購商品,余額記錄。第一次啟動程序時需要記錄工資,第二次啟動程序時談出上次余額
3.允許用戶根據(jù)商品編號購買商品
4.用戶選擇商品后,檢測是否夠,夠就直接扣款,不夠就提醒
5.可隨時退出,退出時,打印移購買商品和余額
商家入口:
1.可以添加商品,修改商品價格
'''
import os,sys

def user_shopping():
while True:
user_salary = input('請輸入你的充值金額:')
if user_salary.isdigit():
user_salary = int(user_salary)
user_shop_file.write(login_name + '\t')
user_shop_file.write(str(user_salary) + '\n')
for item in product_lists:
print(product_lists.index(item),item)
p_index = product_lists.index(item)
while True:
user_choice = input('請輸入你要選擇的商品:')
if user_choice.isdigit():
user_choice = int(user_choice)
if user_choice <= p_index or user_choice >= 0:
p_item = product_lists[user_choice]
p_item[1] = int(p_item[1])
if user_salary >= p_item[1]:
user_salary -= p_item[1]
global shop_lists
shop_lists.append(p_item)
user_shop_file.seek(0)
user_shop_file.write(login_name + '\t')
user_shop_file.write(str(user_salary) + '\n')
print('商品%s已加入購物車,您還剩%s錢'%(p_item[0],user_salary))

        else:
                        print('您的金額不錯,請去充值')
                        print('您已購得'.center(30,'*'))
                        print(shop_lists)
                        sys.exit()
                else:
                    print('請輸入范圍內(nèi)的商品:')
            elif user_choice == 'q':

                sys.exit('退出程序')

            else:('其輸入正確的商品編號')
    else:
        print('請輸入正確的格式')

def user_top():
while True:
user_salary = input('請輸入你要充值的金額:')
if user_salary.isdigit():
user_salary = int(user_salary)
user_salary += int(shop[1])
user_shop_file.seek(0)
user_shop_file.write(login_name + '\t')
user_shop_file.write(str(user_salary) + '\n')
for item in product_lists:
print(product_lists.index(item),item)
p_index = product_lists.index(item)
while True:
user_choice = input('請輸入你要購買的商品:')
user_choice = int(user_choice)
if user_choice <= p_index or user_choice >= p_index:
p_item = product_lists[user_choice]
p_item[1] = int(p_item[1])
if p_item[1] <= user_salary:
user_salary -= p_item[1]
global shop_lists
shop_lists.append(p_item)
user_shop_file.seek(0)
user_shop_file.write(login_name + '\t')
user_shop_file.write(str(user_salary) + '\n')
print('商品%s已加入購物車,您還剩%s錢'%(p_item[0],user_salary))

    else:
                        print('您的金額不錯,請去充值')
                        print('您已購得'.center(30,'*'))
                        print(shop_lists)
                        sys.exit()

            else:
                print('請輸入正確的商品范圍')
    else:
        print('請輸入爭取的格式的格式')

user_name = ''
shop_lists = []
product_lists = []
def product_shop():
user_product_list_file = open('product_file.txt','r+',encoding ='UTF-8')
product_list_item = user_product_list_file.readlines()
for i in product_list_item:
i = eval(i)
product_lists.append(i)

product_shop()
print(product_lists)
user_shop_file =open('user_shop_file.txt','r+')
user_shop_list =user_shop_file.readlines()
for i in user_shop_list:
shop = i.split()

print(i)

if len(user_shop_list) == 0:
login_name = input('請輸入用戶名:')
user_info_file = open('user_info_file.txt','r+')
user_info_list = user_info_file.readlines()
for a in user_info_list:
a = a.split()
if login_name in a:
while True:
login_pwd = input('請輸入密碼')
if login_pwd == a[1]:
print('歡迎進入購物商城')
user_shopping()
else:
print('你輸入的密碼不爭取')

else:
        sys.exit('用戶名不存在')

else:
login_name = input('請輸入用戶名:')
user_info_file = open('user_info_file.txt','r+')
user_info_list = user_info_file.readlines()
for a in user_info_list:
a = a.split()
if login_name in a:
while True:
login_pwd = input('請輸入密碼')
if login_pwd == a[1]:
print('歡迎進入購物商城')
user_top()

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

分享文章:python學(xué)習(xí)之登陸購物-創(chuàng)新互聯(lián)
文章源于:http://jinyejixie.com/article26/coeojg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、網(wǎng)站排名云服務(wù)器、電子商務(wù)、網(wǎng)站營銷品牌網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司
黄浦区| 滕州市| 章丘市| 海城市| 八宿县| 焉耆| 灌云县| 什邡市| 台北县| 乌兰察布市| 渝北区| 桃江县| 新干县| 兰坪| 新化县| 浦江县| 临洮县| 全州县| 获嘉县| 库尔勒市| 镇安县| 如东县| 饶平县| 漾濞| 兰西县| 婺源县| 宁陵县| 双峰县| 西华县| 巫溪县| 邵东县| 保山市| 柳江县| 博罗县| 治县。| 黄平县| 广汉市| 黄冈市| 淮南市| 东丽区| 普定县|