from goods import* goods=[] def pause(): input("回车继续:") def goodsNew (goods): gdsNo = input ("新增商品,请输入商品编号:") gdsName = input ("商品名称:") gdsPrice = input("商品单价:") gds = Goods(0, gdsNo, gdsName, gdsPrice) goods.append(gds) pause() def goodsDelete(): shan=input("请输入你要删除的商品编号:") p=0 while p<len(goods): if goods[p].gdsNo == shan: print("要删除的商品是:") del goods[p] p += 1 pause() def goodsUpdate (goods): chg = input("请输入准确的要修改的商品编号:") i = 0 while i < len (goods): if goods[i] .gdsNo == chg: print("要修改的商品是:", goods[i] .getInfo()) gdsNo = input ("修改商品,请输入商品编号:") gdsName = input ("商品名称:") gdsPrice = input("商品单价:") gdsId = goods[i].gdsId goods[i] = Goods(gdsId, gdsNo, gdsName, gdsPrice) i += 1 pause() def goodsSearch (goods): qry = input("请输入的查询内容:") for good in goods: if good .gdsNo .find(qry) >= 0 or good.gdsName.find(qry) >= 0: print("找到的商品有:", good.getInfo()) pause() def clean (): i = 0 while i < 15 : print() i += 1 menus = ["商品管理系统:-----", "1.新增商品", "2.显示已有商品", "3.查找商品", "4.修改已有商 品", \ "5.删除已有商品", "0.退出", "-------------"] def goodsMgrDo (): while True : clean() for m in menus: print (m) sel = input ("请输入一个整数,选择要完成的功能:") if sel == "0": break; elif sel == '1': goodsNew(goods) elif sel == '2': goodsSearch(goods) elif sel == '3': goodsUpdate(goods) elif sel == '4': goodsDelete() goodsMgrDo() 将前面句子中的商品改成供应商
时间: 2024-04-01 17:32:46 浏览: 78
好的,修改后的代码如下:
from supplier import* suppliers=[]
def pause():
input("回车继续:")
def supplierNew(suppliers):
supNo = input("新增供应商,请输入供应商编号:")
supName = input("供应商名称:")
supContact = input("联系方式:")
sup = Supplier(0, supNo, supName, supContact)
suppliers.append(sup)
pause()
def supplierDelete():
shan = input("请输入你要删除的供应商编号:")
p = 0
while p < len(suppliers):
if suppliers[p].supNo == shan:
print("要删除的供应商是:")
del suppliers[p]
p += 1
pause()
def supplierUpdate(suppliers):
chg = input("请输入准确的要修改的供应商编号:")
i = 0
while i < len(suppliers):
if suppliers[i].supNo == chg:
print("要修改的供应商是:", suppliers[i].getInfo())
supNo = input("修改供应商,请输入供应商编号:")
supName = input("供应商名称:")
supContact = input("联系方式:")
supId = suppliers[i].supId
suppliers[i] = Supplier(supId, supNo, supName, supContact)
i += 1
pause()
def supplierSearch(suppliers):
qry = input("请输入的查询内容:")
for sup in suppliers:
if sup.supNo.find(qry) >= 0 or sup.supName.find(qry) >= 0:
print("找到的供应商有:", sup.getInfo())
pause()
def clean():
i = 0
while i < 15:
print()
i += 1
menus = ["供应商管理系统:-----",
"1.新增供应商",
"2.显示已有供应商",
"3.查找供应商",
"4.修改已有供应商",
"5.删除已有供应商",
"0.退出",
"-------------"]
def supplierMgrDo():
while True:
clean()
for m in menus:
print(m)
sel = input("请输入一个整数,选择要完成的功能:")
if sel == "0":
break
elif sel == '1':
supplierNew(suppliers)
elif sel == '2':
supplierSearch(suppliers)
elif sel == '3':
supplierUpdate(suppliers)
elif sel == '4':
supplierDelete()
supplierMgrDo()
阅读全文