python編寫庫存管理 python編寫商品管理

2021-10-16 19:27:07 字數 2194 閱讀 3641

# 1、實現乙個商品管理的程式。

# #輸出1,新增商品 2、刪除商品 3、檢視商品

# 新增商品:

# 商品的名稱:*** 商品如果已經存在的話,提示商品商品已經存在

# 商品的**:***x 數量只能為大於0的整數

# 商品的數量:***,數量只能為大於0的整數

# 2、刪除商品:

# 輸入商品名稱:

# iphone 如果輸入的商品名稱不存在,要提示不存在

# 3、檢視商品資訊:

# 輸入商品名稱:

# iphone:

# **:***

# 數量是:***

# all:

# print出所有的商品資訊

import json

def add_product():

product = input('請輸入商品名稱:').strip()

count = input('請輸入商品數量:').strip()

price = input('請輸入商品**:').strip()

f = open('product.json', 'a+', encoding='utf-8')

f.seek(0)

products = json.load(f)

if product == '':

print('商品名稱不能為空')

elif product in products:

print('商品已存在')

elif not count.isdigit():

print('商品數量必須為正整數')

elif not price.isdigit():

print('商品**必須為正整數')

else:

products[product] = {}

products[product]['count'] = int(count)

products[product]['price'] = int(price)

f.seek(0)

f.truncate()

json.dump(products, f, indent=4, ensure_ascii=false)

f.close()

def show_product(product):

f = open('product.json', encoding='utf-8')

products = json.load(f)

f.close()

if (product=='all'):

return products

elif not (product in products):

print('商品不存在')

else:

#print(products[product])

return product+':\n 數量:'+str(products[product]['count'])+'\n **:'+str(products[product]['price'])

def del_product(product):

f = open('product.json', 'a+', encoding='utf-8')

f.seek(0)

products = json.load(f)

if not (product in products):

print('商品不存在')

else:

del products[product]

f.seek(0)

f.truncate()

json.dump(products, f, indent=4, ensure_ascii=false)

f.close()

print("輸出1、新增商品 2、刪除商品 3、檢視所有商品")

choice=input()

if choice=="1":

add_product()

elif choice=="2":

product=input('請輸入要刪除的商品名稱:')

del_product(product)

elif choice=="3":

product=input('請輸入要查詢的商品名稱:')

print(show_product(product))

else:

print('輸入有誤')

ABC 庫存管理

為了使有限的時間 資金 人力 物力等企業資源能得到更有效的利用,應對庫存物資進行分類,將管理的重點放在重要的庫存物資上而進行分類管理和控制,即依據庫存物資重要程度的不同,以某類庫存貨物品種數占物資總品種數的百分數和該類物資金額佔庫存物資總金額的百分數大小為標準,將庫存物資分為 a b c 三類進行分...

MM庫存管理

繼續學習sap的mm模組。今天看了mm中的inventory management。對庫存管理有了一定的了解。首先大家知道像沃爾瑪這樣的零售業的利潤表裡,利潤 銷售收入 採購成本。採購成本如何計算呢,很簡單,初始庫存總共採購成本100塊,結算時剩餘庫存成本30塊,那麼銷售出去的採購成本就是100 3...

複式庫存管理

複式庫存沒有入庫 出庫的概念,取而代之所有的操作都是庫位之間的移動 stock moves 一 系統中庫位的型別介紹 系統預設定義了以下幾種庫位型別 1.supplier vendor location 商庫位 商供貨入庫的源庫位,虛擬庫位 2.view 檢視 用於建立倉庫的庫位結構,聚合所屬子庫位...