Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 仓库系统的分类_Python_Python 3.x - Fatal编程技术网

Python 仓库系统的分类

Python 仓库系统的分类,python,python-3.x,Python,Python 3.x,我目前有一个仓库系统,据我所知不可能得到一个好的分拣系统。有不同的方法吗?您将如何解决它们 我试着用数量将它们按最大数量到最小数量进行排序,但在列表中后退一步后,我无法得到它们 def start(x, warehouse=[]): 'x is correct until this point' item_name = input("whats the name of the product?") item_amount = input("Whats the amount you want

我目前有一个仓库系统,据我所知不可能得到一个好的分拣系统。有不同的方法吗?您将如何解决它们

我试着用数量将它们按最大数量到最小数量进行排序,但在列表中后退一步后,我无法得到它们

def start(x, warehouse=[]):
 'x is correct until this point'
 item_name = input("whats the name of the product?")
 item_amount = input("Whats the amount you want to buy?")
 item=item_name+"="+item_amount
 item.replace(" ", "")
 warehouse.append(item)

 decision=input("Do you want to add more items? Y/N")

 if decision=="Y":
     start(x, warehouse)
 if decision=="N":
     for x in warehouse:
         print(x)
     print("Do you want them to be sorted? Y/N")

print("The only reason for this program to exist is, to help you with your shopping list :D")
x = 0
lager = [""]
start(x, warehouse)

我认为在您的情况下,最简单的方法是将所有项目和金额存储在元组列表中,如下所示:

def start(warehouse=[]):
   item_name = input("whats the name of the product? ").strip()
   item_amount = input("Whats the amount you want to buy? ").strip()

   warehouse.append((item_name,int(item_amount)))

   decision=input("Do you want to add more items? (Y/N) ")

   if decision=="Y":
       start(warehouse)
   if decision=="N":
       for x in sorted(warehouse,key=lambda x:x[1]):
           print("{}={}".format(*x))
       print("Do you want them to be sorted? Y/N")

不太清楚你在问什么。预期的输出是什么?您得到的输出是什么?也读